public static void main(String[] args) {
        //OLD
//        List groceryList = new ArrayList();
//        groceryList.add("Chocolate");
//        groceryList.add("Milk");
//        groceryList.add("Yogurt");
//        groceryList.add("Graham crackers");
//        
//        //had to cast prior to JDK5:
//        String item = (String)groceryList.get(1);
//        System.out.println(groceryList.size());
//        groceryList.remove(2);
//        System.out.println(groceryList.size());
//        
//        for(int i=0; i < groceryList.size(); i++){
//            String s = (String)groceryList.get(i);
//            System.out.println(s);
//        }

        //NEW
        //after JDK5, you can specify object type in declaration
        List<String> groceryList = new ArrayList<String>();
        //for JDK 7 only, this declaration is allowed:
        //List<String> groceryList = new ArrayList<>();
        groceryList.add("Chocolate");
        groceryList.add("Milk");
        groceryList.add("Yogurt");
        groceryList.add("Graham crackers");
        groceryList.add("Milk");

        //no casting needed
        for (String s : groceryList) {
            System.out.println(s);
        }
        System.out.println("-----------------------------------");

        List<String> getTheseToo = new ArrayList<String>();
        getTheseToo.add("Ice cream");
        getTheseToo.add("Napkins");
        for (String s : getTheseToo) {
            System.out.println(s);
        }

        System.out.println("-----------------------------------");
        groceryList.addAll(getTheseToo);
        for (String s : groceryList) {
            System.out.println(s);
        }

        System.out.println("-----------------------------------");
        groceryList.remove(4);
        groceryList.set(3, "Sprinkles");

        for (String s : groceryList) {
            System.out.println(s);
        }

        //The following will swap 2 items in the list: item 5 (Napkins) is 
        //stored in the String tmp; at index 5 the value is set to item 3
        //(Sprinkles); tmp (Napkins) is then set at index 3.
        //Napkins is now #3 and Sprinkles is now #5 
        swap(groceryList, 5, 3);

        System.out.println("------After swap------------------------");
        for (String s : groceryList) {
            System.out.println(s);
        }

        shuffle(groceryList, new Random());
        System.out.println("------After shuffle---------------------");
        for (String s : groceryList) {
            System.out.println(s);
        }

        Collections.sort(groceryList);
        System.out.println("------After sort---------------------");
        for (String s : groceryList) {
            System.out.println(s);
        }

        Collections.reverse(groceryList);
        System.out.println("------After reverse---------------------");
        for (String s : groceryList) {
            System.out.println(s);
        }

        Collections.shuffle(groceryList);
        System.out.println("------After collections shuffle---------------");
        for (String s : groceryList) {
            System.out.println(s);
        }



    }