Eg:
public static void main(String[]args){
//creation of
Arraylist with string arguments
//adding elements to
Arraylist
ArrayList<String>
al=new ArrayList<String>();
al.add("India");
al.add("US");
al.add("Australia");
al.add("Germany");
al.add("Europe");
//Before Sorting
System.out.println(al);
//Sort Statement
Collections.sort(al);
//After Sorting
//After Sorting
System.out.println(al);
}
Output
//Before Sorting
Output:[India,US,Australia,Germany,Europe]
//After Sorting
Output:[Australia,Europe,Germany,India,US,]
0 comments:
Post a Comment