/**
Testing
of ArrayList with Collections.sort( )
Note:
Compiling this program using JSE 6.0 will generate warnings. Ignore them for
now. The generated .class file still works.
**/
import
java.util.Arrays;
import
java.util.Collections;
import
java.util.ArrayList;
public
class ArrayListTest {
       public
static void main (String args[]) {
             ArrayList
animals = new ArrayList();
             animals.add("snake");
             animals.add("kangaroo");
             animals.add("wombat");
             animals.add("bird");
             for
(int i=0; i<animals.size(); i++) {
                    System.out.println("animal
" + i + " : " + (String) animals.get(i));
             }
             Collections.sort(animals);
//sort the ArrayList
             for
(int i=0; i<animals.size(); i++) {
                    System.out.println("animal
" + i + " : " + (String) animals.get(i));
             }
       } //main()
} //
ArrayListTest class