import java.util.*;

public class StackExample {
  public static void main(String [] args) {
    Stack stack = new Stack();

    // Loop over the command line arguments and stick them on a stack
    for (int i=0; i<args.length; i++) {
      stack.push(args[i]);
      System.out.println("Putting " + args[i] + " on the stack");
    }

    // Now remove all the items from the stack, printing them out
    while (! stack.empty()) {
      Object obj = stack.pop();  // The object is really a String
      System.out.println("Popped " + obj + " from the stack");
    }
  }
}

// paulmac@nautilus: javac StackExample.java
// paulmac@nautilus: java StackExample
// paulmac@nautilus: java StackExample apple blueberry maple banana
// Putting apple on the stack
// Putting blueberry on the stack
// Putting maple on the stack
// Putting banana on the stack
// Popped banana from the stack
// Popped maple from the stack
// Popped blueberry from the stack
// Popped apple from the stack
// paulmac@nautilus: 
