import java.util.*;
//------------------------------------------------------------------------------
// Create, sort, and print ArrayLists (using generics)
//------------------------------------------------------------------------------

public class arrayList2 
{
    public static void main(String[] args) 
    {
        //Creating an ArrayList Collection class using <generic> ---------------

        ArrayList<String> days_of_week = new ArrayList<String>();

        days_of_week.add("Sunday");
        days_of_week.add("Monday");
        days_of_week.add("Tuesday");
        days_of_week.add("Wednesday");
        days_of_week.add("Thursday");
        days_of_week.add("Friday");
        days_of_week.add("Saturday");
        
        //Printing collection content ------------------------------------------

        System.out.println(days_of_week);       //entire collection? yes
        System.out.println();

        String d = days_of_week.get(0);         //No need to (cast) down        
        System.out.println("The first day is: " + d);
 
        //Using the for loop ---------------------------------------------------

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

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

        for (String day : days_of_week)
        {
            System.out.println(day);
        }
        System.out.println();

        //Sorting, and printing - implicit toString() --------------------------

        Collections.sort(days_of_week, Collections.reverseOrder(String.CASE_INSENSITIVE_ORDER));

        System.out.println(days_of_week);
    }
}