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

@SuppressWarnings("unchecked")          //annotation to suppress compile warnings

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

        ArrayList  days_of_week = new ArrayList (10);

        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 = (String) days_of_week.get(0);            //must (cast) down

        System.out.println("The first day is: " + d);

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

        for (int i=0; i<days_of_week.size(); i++)
        {
            String day = (String) days_of_week.get(i);      //must cast down
            System.out.println(day);
        }
        System.out.println();

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

        for (Object day : days_of_week)
        {
            String day2 = (String) day;                     //must cast down
            System.out.println(day2);
        }
        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);
    }
}