/* * This was used to show code reuse in class. The same stack is used * to store strings and integers. Note that there are "two flavors" * of integers: one is a primitive like the C version; the other is a * subclass of an "Object". This example only works for the Object * version. */ import MyStack; class StackTest { public static void main(String[] args) { MyStack s1 = new MyStack(); s1.push ("first"); s1.push ("second"); while (!s1.empty()) System.out.println(s1.pop()); MyStack s2 = new MyStack(); s2.push(new Integer(1)); s2.push(new Integer(2)); while (!s2.empty()) System.out.println(s2.pop()); } }