class ParamStackProgTest {
public static void main (String [] args) {
ParamStack <String> stck = new ParamStack <String> (args[0]);
int i;
for (i = 1; i < args.length; i++)
stck.put (args[i]);
for (i = 0; i < args.length + 4; i++)
System.out.println (stck.get());
}
static class ParamStack <P> {
P v;
ParamStack <P> n;
ParamStack (P v) {
this.v = v;
this.n = null;
}
void put (P v) {
ParamStack <P> ptr = new ParamStack (v);
ptr.n = this.n;
this.n = ptr;
}
P get () {
P v;
if (this.n == null)
v = this.v;
else {
v = this.n.v;
this.n = this.n.n;
}
return v;
}
}
}