Sunday, February 12, 2017

Java Program to sort List(ArrayList) Elements in ascending order(default sorting order).

import java.util.ArrayList;
import java.util.Collections;
import static java.lang.System.out;
class SortList
{
public static void main(String...alt)
{
ArrayList al=new ArrayList();
al.add("z");
al.add("a");
al.add("k");
al.add("z");
al.add("n");
out.println("Before Sorting : "+al);
Collections.sort(al);
out.println("After Sorting : "+al);
}
}

Share this

0 Comment to "Java Program to sort List(ArrayList) Elements in ascending order(default sorting order)."

Post a Comment