//SymNode is the node to contain the integer to be placed on stack class SymNode { int value; SymNode next; public SymNode (int value, SymNode next) { this.value = value; this.next = next; } } //CStack is the dynamic stack (i.e. a linked list) public class CStack { SymNode top; //Top keeps track of next element to pop //constructor just creates an empty stack public CStack () { top = null; } //Extra method to see if stack is empty - not necessary, but nice public boolean isEmpty () { return (top == null); } //push - should be saved on top of stack public void push (int value) { //creates a new node from an int value and set it //to top and to point to old top. top = new SymNode (value, top); } //pop - should return top and new top is node underneath public int pop () { int v = top.value; top = top.next; return v; } }