//  File:  StackQueue.java

import java.io.*;
import java.util.*;

/**
 * Show how to use a Java Stack -- push(), pop(), peek(); <br>
 * and, show how to access individual stack elements
 * 
 * @author Bary W Pollack
 * @version Sept 29, 1999 - Created
 * @see main
 */

public class StackQueue {

    /**
     * The main method -- show how to use a Java Stack
     * 
     * @param argv unused
     */
        
    public static void main (String [] argv) {
        System.out.println("\nUsing a Java Stack...\n");
        
        System.out.println("Create a Stack...");
        Stack s = new Stack();
        
        System.out.println("Load it with 5 integers:  101..105");
        for (int i = 0; i < 5; i++)
            s.push(new Integer(101+i));
            
        System.out.println("Look at the contents from bottom to top");
        for (int i = 0; i < s.size(); i++)
            System.out.println(i + ": " + ((Integer) s.elementAt(i)).intValue());
            
        System.out.println("Peek at the top: " + s.peek());
        
        System.out.println("Pop a few...");
        for (int i = 0; i < 3; i++)
            System.out.println(s.pop());
        
        System.out.println("\n** Fini **");
    }
    
}

/*..... Execution output...

Using a Java Stack...

Create a Stack...
Load it with 5 integers:  101..105
Look at the contents from bottom to top
0: 101
1: 102
2: 103
3: 104
4: 105
Peek at the top: 105
Pop a few...
105
104
103

** Fini **

..... */

