Here you can find the source of max(Collection
public static int max(Collection<Integer> collection)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; public class Main { public static int max(Collection<Integer> collection) { List<Integer> list = new ArrayList<Integer>(collection); Collections.sort(list);//from w ww . j a v a 2 s. com return list.get(list.size() - 1); } }