Java tutorial
//package com.java2s; import java.util.Map; public class Main { /** * This method returns the highest value of a map. * This value class of the map has to implement comparable * * @param map Map * @param <K> Key class * @param <V> Value class implementing Comparable * @return Highest values in the map */ public static <K, V extends Comparable> V getHighestValue(Map<K, V> map) { V highestValue = null; for (Map.Entry<K, V> entry : map.entrySet()) { if (highestValue == null || entry.getValue().compareTo(highestValue) > 0) { highestValue = entry.getValue(); } } return highestValue; } }