public class Sort1
1: // Fig. 19.8: Sort1.java
2: // Using algorithm sort.
3: import java.util.List;
4: import java.util.Arrays;
5: import java.util.Collections;
6:
7: public class Sort1
8: {
9: private static final String suits[] =
10: { "Hearts", "Diamonds", "Clubs", "Spades" };
11:
12: // display array elements
13: public void printElements()
14: {
15: List< String > list = Arrays.asList( suits ); // create List
16:
17: // output list
18: System.out.printf( "Unsorted array elements:\n%s\n", list );
19:
20: Collections.sort( list ); // sort ArrayList
21:
22: // output list
23: System.out.printf( "Sorted array elements:\n%s\n", list );
24: } // end method printElements
25:
26: public static void main( String args[] )
27: {
28: Sort1 sort1 = new Sort1();
29: sort1.printElements();
30: } // end main
31: } // end class Sort1
32:
33:
34: /**************************************************************************
35: * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and *
36: * Pearson Education, Inc. All Rights Reserved. *
37: * *
38: * DISCLAIMER: The authors and publisher of this book have used their *
39: * best efforts in preparing the book. These efforts include the *
40: * development, research, and testing of the theories and programs *
41: * to determine their effectiveness. The authors and publisher make *
42: * no warranty of any kind, expressed or implied, with regard to these *
43: * programs or to the documentation contained in these books. The authors *
44: * and publisher shall not be liable in any event for incidental or *
45: * consequential damages in connection with, or arising out of, the *
46: * furnishing, performance, or use of these programs. *
47: *************************************************************************/