Eg:
ArrayList<String> al=new ArrayList<String>();
//After Sorting
//After Sorting
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,Collections.reverseOrder());
//After Sorting
Collections.sort(al);
}
Output:
//Before Sorting
[India,US,Australia,Germany,Europe]
//After Sorting
Output:[US,India,Germany,Europe,Australia]
0 comments:
Post a Comment