Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsMaxExample3 { public static void main(String[] args) { //Create collections lists List
list = Arrays.asList(201, 101, 1001, 140, 2501); //Comparing using order of the specified comparable Integer max = Collections.max(list, Collections.reverseOrder()); System.out.println("Output: "+max); } }
Output