How to Sort ArrayList in Java ?

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class SortArrayList {

public static void main(String args[]) {
List<String> list=new ArrayList<String>();

list.add("z");
list.add("s");
list.add("a");

Collections.sort(list);

System.out.println("Sorted ArrayList"+list);
}
}

Comments