Java examples for Collection Framework:Collections Utility Methods
Collections method sort.
import java.util.List; import java.util.Arrays; import java.util.Collections; public class Main { public static void main(String[] args) {// w w w . j a v a 2 s .c o m String[] suits = {"Hearts", "Diamonds", "Clubs", "Spades"}; // Create and display a list containing the suits array elements List<String> list = Arrays.asList(suits); System.out.printf("Unsorted array elements: %s%n", list); Collections.sort(list); // sort ArrayList System.out.printf("Sorted array elements: %s%n", list); } }