Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsReverseOrderExample1 { public static void main(String[] args) { //Create linked list object LinkedList
list = new LinkedList
(); //Add values in the list list.add(10); list.add(-20); list.add(50); list.add(90); list.add(-15); //Sort the list and return comparator for reverse order Collections.sort(list, Collections.reverseOrder()); System.out.println("List sorted in ReverseOrder: "); System.out.println(list); } }
Output