Here you can find the source of max(Collection
public static <T extends Comparable<T>> T max(Collection<T> elems)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static <T extends Comparable<T>> T max(Collection<T> elems) { T max = null;//from ww w . j a v a 2 s . co m for (T t : elems) { if (max == null || max.compareTo(t) < 0) { max = t; } } return max; } }