Here you can find the source of max(T... values)
@SafeVarargs public static <T extends Comparable<? super T>> T max(T... values)
//package com.java2s; //License from project: Apache License public class Main { @SafeVarargs public static <T extends Comparable<? super T>> T max(T... values) { T result = null;//w ww. j a va 2 s . c om if (values != null) { for (T value : values) { if (compare(value, result, false) > 0) { result = value; } } } return result; } public static <T extends Comparable<? super T>> int compare(T c1, T c2) { return compare(c1, c2, false); } public static <T extends Comparable<? super T>> int compare(T c1, T c2, boolean nullGreater) { if (c1 == c2) { return 0; } else if (c1 == null) { return nullGreater ? 1 : -1; } else if (c2 == null) { return nullGreater ? -1 : 1; } return c1.compareTo(c2); } }