About lists               The colored to comment.

/**

*/

import java.util.*;

public class TheLists 
{
public static void main(String [] args) 
	{
	List  TheList1 = new ArrayList  ();
	
	System.out.println("\n\tHow is the list TheList filled:");
	System.out.println("\n\t" + TheList1);
	
	TheList1.add("1");
	TheList1.add("2");
	TheList1.add("3");
	TheList1.add("4");
	TheList1.add("4");
	TheList1.add("5");
	System.out.println("\n\tWe added elemnts in the list TheList1 :");
	System.out.println("\n\t" + TheList1);
	
	swap(TheList1,0,4);
	System.out.println("\n\tWe swapped the First and the Fifth elements in the ist TheList1 :");
	System.out.println("\n\t" + TheList1);	
	
	swap(TheList1,2,3);
	System.out.println("\n\tWe swapped the Third and the Fourth elements fron the latter list :");
	System.out.println("\n\t" + TheList1);
	
	Collections.shuffle(TheList1) ;
	System.out.println("\n\tWe shuffled the latter list :");
	System.out.println("\n\t" + TheList1);
	
	Collections.reverse(TheList1) ;
	System.out.println("\n\tWe reversed the latter list :");
	System.out.println("\n\t" + TheList1);
		
	Collections.reverse(TheList1) ;
	System.out.println("\n\tWe reversed the latter list :");
	System.out.println("\n\t" + TheList1);
	
	System.exit(0);
	

	
	}

public static void swap(List  a, int i, int j) 
	{
	Object tempo = a.get(i);
	a.set(i, a.get(j));
	a.set(j, tempo);
	}
}


 Execution:

C:\Java>java TheLists

         How is the list TheList filled:

        []

         We added elemnts in the list TheList1 :

        [1, 2, 3, 4, 4, 5]

         We swapped the First and the Fifth elements in the ist TheList1 :

        [4, 2, 3, 4, 1, 5]

         We swapped the Third and the Fourth elements fron the latter list :

        [4, 2, 4, 3, 1, 5]

         We shuffled the latter list :

        [4, 1, 2, 5, 3, 4]

         We reversed the latter list :

        [4, 3, 5, 2, 1, 4]

         We reversed the latter list :

        [4, 1, 2, 5, 3, 4]

C:\Java>