/**
* Title: ListPrinting
* Description: Exploration of printing a list (container)
* @author hollingd@cs.rpi.edu
*/
import java.util.*;
class ListPrinting {
public static void main(String [] args ) {
// Create an ArrayList object
ArrayList x = new ArrayList();
// Populate with 10 random Integer objects
Random r = new Random();
for (int i=0;i<10;i++) {
x.add( new Integer(r.nextInt(100)));
}
System.out.println("------ Initial Order -----");
// what happens if we print the whole thing?
System.out.println(x);
// Sort the ArrayList (possible because Integer implements
// the interface Comparable)
Collections.sort((List)x);
// print new order
// print using random access (get)
System.out.println("------ sorted using sort() -----");
System.out.println(x);
}
}