Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsMaxExample1 { public static void main(String[] args) { //Create collection List
list = new ArrayList
(); //Add values in the list list.add("A"); list.add("B"); list.add("E"); list.add("C"); list.add("S"); //Comparing using order of the specified comparable System.out.println("Max val: " + Collections.max(list,null)); } }
Output