/** This program is intended to be used with the book "Java 6 -- What Do You Want To Do?"
 * by Steven P. Warr and is distributed free of charge and without and expectations of remuneration.
 * Chapter DAT   NOTE most program names begin with the title of the chapter in which
 * they are intended to be used.   Copyright 2010 Steven P. Warr All rights reserved
	Stack Example.
 */

import java.io.*;   		//needed so you can use the File class
import java.util.*;  		//needed for Lists
public class Dat03
{
	public static void main(String[ ] args) throws IOException
		{
            Stack <Character> c = new Stack <Character>();                                  
			c.push('A');              // adds letter to the top of the Stack                     
			c.push('B');                                              
			c.push('C');                                              
			System.out.println(c);    		//[A, B, C]                                          
			System.out.println(c.pop());    // prints and removes C
			System.out.println(c);    		//[A, B]                                          
			c.push('D');                                              
			c.push('E');                                              
			System.out.println(c.pop());    // prints and removes E
			System.out.println(c);    		//[A, B, D]                                          
			c.push('F');                                              
			
			char let = c.pop ();              
			char name = (Character)c.pop ();  // Wrapper class cast
			//System.out.println(let);                                              

			System.out.println(c);    		//[A, B]                                          
            
			for(char x:c)
			    System.out.println(x);   // for - each automates get 
            
        }

}
