public class GenericStack { GenericList list; //This generic stack uses a generic list to store the elements. public GenericStack() { list = new GenericList(); //instantiate the underlying list. } public void push (T item) { GenericNode node = new GenericNode(item); list.insert(node); } public T peek() { return list.getVal(0); } public T pop() { T res = list.getVal(0); list.remove(); return res; } public int size() { return list.length(); } public void print() { System.out.print("Stack: "); list.print(); System.out.println(); } }