Java Collections.max(Collection <? extends T> coll)
Syntax
Collections.max(Collection <? extends T> coll) has the following syntax.
public static <T extends Object & Comparable <? super T>> T max(Collection <? extends T> coll)
Example
In the following code shows how to use Collections.max(Collection <? extends T> coll) method.
/*from w w w. j ava 2 s . 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.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »