import java.util.*;
//------------------------------------------------------------------------------
//Creating and using a Stack.  (a Stack extends a Vector)  
//------------------------------------------------------------------------------

public class stack1 
{
    public static void main(String[] args) 
    {
        Stack<String> shirtsOnShelf = new Stack<String>();      //using generics

        shirtsOnShelf.push("White");                            //add to end
        shirtsOnShelf.push("Blue");                             //add to end
        shirtsOnShelf.push("Brown");                            //
        shirtsOnShelf.push("Stripes");                          //top element
        
        //Printing collection content

        System.out.println(shirtsOnShelf);                      //call the toString() method
        System.out.println();

        System.out.println(shirtsOnShelf.search("Brown"));      //2nd from the top
        System.out.println();

        String todaysShirt = shirtsOnShelf.pop();               //remove from end
        
        System.out.println("Today's shirt is: " + todaysShirt); //print the popped shirt
            
        System.out.println(shirtsOnShelf.isEmpty());            //in super class
        System.out.println(shirtsOnShelf.empty());              //in Stack class
        System.out.println();
        
        //Using the for loop ---------------------------------------------------

        for (int i=0; i<shirtsOnShelf.size(); i++)
        {
            System.out.println(shirtsOnShelf.get(i));
        }
        System.out.println();

        //Using the enhanced for loop ------------------------------------------

        for (String shirt : shirtsOnShelf)
        {
            System.out.println(shirt);
        }
    }
}