... Stack<Integer> stack, int[] values) { 57          System.out.printf("%nPushing elements onto integerStack%n");
 58
 59          // push elements to Stack
 60          for (int value : values) {
 61             System.out.printf("%d ", value);
 62             stack.push(value); // push onto integerStack
 63          }
 64       }
 65
 66       // test pop method with integer stack
 67       private static void testPopInteger(Stack<Integer> stack) {
 68          // pop elements from stack
 69          try {
 70             System.out.printf("%nPopping elements from integerStack%n");
 71             int popValue; // store element removed from stack
 72
 73             // remove all elements from Stack
 74             while (true) {
 75                popValue = stack.pop(); // pop from intStack
 76                System.out.printf("%d ", popValue);
 77             }
 78          }
 79          catch(NoSuchElementException noSuchElementException) {
 80             System.err.println();
 

Get Java How To Program, Late Objects, 11th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.