Java tutorial
//package com.java2s; import java.util.Collection; import java.util.Iterator; public class Main { /** * @param coll {@link Collection} any collection object containing zero or more elements,can't be null. * @return {@link Number} the maximum value available in the collection. */ public static Number max(Collection<? extends Number> coll) { Iterator<? extends Number> i = coll.iterator(); Number candidate = i.next(); while (i.hasNext()) { Number next = i.next(); if (next.doubleValue() - candidate.doubleValue() > 0) candidate = next; } return candidate; } }