Mega Code Archive

 
Categories / Java Book / 005 Collection
 

0335 Get the max and min value from a Collection

static<T extends Object & Comparable<? super T>>T max(Collection<? extends T> coll) Returns the maximum element of the given collection, according to the natural ordering of its elements. static<T> T max(Collection<? extends T> coll, Comparator<? super T> comp) Returns the maximum element of the given collection, according to the order induced by the specified comparator. static<T extends Object & Comparable<? super T>>T min(Collection<? extends T> coll) Returns the minimum element of the given collection, according to the natural ordering of its elements. static<T> T min(Collection<? extends T> coll, Comparator<? super T> comp) Returns the minimum element of the given collection, according to the order induced by the specified comparator.