Sunday, April 29, 2012

Sort List of String in reverse Order Using Collections

public class SortingStringInReverseOrder {
 public static void main(String[] args) {
 List<String> strList = new ArrayList<String>();
 strList.add("aaaa");
 strList.add("bbbb");
 strList.add("cccc");
 strList.add("dddd");
 strList.add("eeee");
 strList.add("ffff");
 System.out.println("strList "+strList);
 Comparator comp = Collections.reverseOrder();
 Collections.sort(strList, comp);
 System.out.println("strList "+strList);
 }
}

No comments:

Post a Comment