public class IntegerArrayStack extends IntegerStack { IntegerArrayStack() { this(10); } IntegerArrayStack(int capacity) { super(capacity); } /** Returns the value in the stack at position pos. The bottom of the stack has position 0. */ public int valueAt(int pos) { return stack[pos]; } public static void main(String[] args) { IntegerArrayStack is = new IntegerArrayStack(); // int n = is.pop(); this should cause an exception // int n = is.top(); this should cause an exception if (is.isEmpty()) System.out.println("stack is empty"); else System.out.println("stack is not empty"); for (int i = 0; i < 10; i++) is.push(i); is.push(10); System.out.println("stack before popping: " + is); System.out.println(is.pop()); System.out.println("stack after popping: " + is); System.out.println("top of stack is: " + is.top()); for (int i = 0; i < 10; i++) System.out.println(is.valueAt(i) + " "); } }