Java map取value最大值和最小值

    /**
     * 求Map<K,V>中Value(值)的最小值
     * 
     * @param map
     * @return
     */
    public static Object getMinValue(Map<Integer, Integer> map) {
        if (map == null)
            return null;
        Collection<Integer> c = map.values();
        Object[] obj = c.toArray();
        Arrays.sort(obj);
        return obj[0];
    }
    /**
     * 求Map<K,V>中Value(值)的最大值
     * 
     * @param map
     * @return
     */
    public static Object getMaxValue(Map<Integer, Integer> map) {
        if (map == null)
            return null;
        int length =map.size();
        Collection<Integer> c = map.values();
        Object[] obj = c.toArray();
        Arrays.sort(obj);
        return obj[length-1];
    }
原文地址:https://www.cnblogs.com/xiaoblog/p/4118022.html