Here you can find the source of max(List
public static <V extends Comparable<V>> V max(List<V> arg)
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.List; public class Main { public static <V extends Comparable<V>> V max(List<V> arg) { if (arg == null) { return null; }/*from w w w.j ava 2s. c o m*/ if (arg.size() == 1) { return arg.get(0); } V max = arg.get(0); for (V each : arg) { if (max.compareTo(each) < 0) { max = each; } } return max; } public static <V> int size(Collection<V> arg) { return null == arg ? 0 : arg.size(); } }