| 9 | // 3 stack pointers to keep track of the index of the top element |
| 10 | static int [] stackPointer = {-1, -1, -1}; |
| 11 | public static void main(String [] args) throws Exception { |
| 12 | push(2, 4); |
| 13 | System.out.println("Peek 2: " + peek(2)); |
| 14 | push(0, 3); |
| 15 | push(0, 7); |
| 16 | push(0, 5); |
| 17 | System.out.println("Peek 0: " + peek(0)); |
| 18 | pop(0); |
| 19 | System.out.println("Peek 0: " + peek(0)); |
| 20 | pop(0); |
| 21 | System.out.println("Peek 0: " + peek(0)); |
| 22 | } |
| 23 | |
| 24 | static void push(int stackNum, int value) throws Exception { |
| 25 | /* Check that we have space for the next element */ |