Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsMinExample3 { public static void main(String[] args) { //Create link list object List
list = new LinkedList
(); //Populate the list list.add(-80); list.add(40); list.add(-50); list.add(20); //Comparing using order of the specified comparable System.out.println("Min val: "+Collections.min(list)); System.out.println("Min val in reverse order: "+Collections.min(list, Collections.reverseOrder())); } }
Output