Collections.max(Collection <? extends T> coll) has the following syntax.
public static <T extends Object & Comparable <? super T>> T max(Collection <? extends T> coll)
In the following code shows how to use Collections.max(Collection <? extends T> coll) method.
// w ww. j a v a 2s. com import java.util.Collections; import java.util.LinkedList; import java.util.List; public class Main { public static void main(String args[]) { // create link list object List<Integer> list = new LinkedList<Integer>(); // populate the list list.add(-1); list.add(4); list.add(-5); list.add(1); System.out.println("Max value is: " + Collections.max(list)); } }
The code above generates the following result.