Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsSortExample2 { public static void main(String[] args) { //Create an array of string objects String str[] = { "Java","Python","Android","One","Ruby","Node.js"}; //Create list List
list = new ArrayList<>(Arrays.asList(str)); System.out.println("Value before sort: "+list); //Sort the list according to specified comparator Collections.sort(list,Collections.reverseOrder()); System.out.println("Sort Value according to specified comparator: "+list); } }
Output