Java tutorial
//package com.java2s; import java.util.Collection; import java.util.Iterator; public class Main { @SuppressWarnings({ "rawtypes", "unchecked" }) public static <E> E maximumValue(Collection<E> c) { Iterator<E> iterator = c.iterator(); E e = iterator.next(); while (iterator.hasNext()) { E current = iterator.next(); if (((Comparable) e).compareTo((Comparable) current) > 0) { e = current; } } return e; } }