/* * This was used in class to discuss: "helper classes", object * references (pointers, or the lack thereof), linked list, garbage * collection. */ class MyNode { Object item; MyNode next; MyNode(Object it) { item = it; next = null; } MyNode(Object item, MyNode next) { this.item = item; this.next = next; } } public class MyStack { MyNode list = null; public MyStack() {} public void push(Object item) { list = new MyNode(item, list); } public Object pop() { Object obj = list.item; list = list.next; return obj; } public boolean empty() { return list == null; } }