zoukankan      html  css  js  c++  java
  • 获取Map中Value(值)的最小值和最大值

    public class MapMinMaxvalue {
        public static void main(String[] args) {
            Map<Object, Object> map=new HashMap<Object, Object>();
            map.put("2", 5);
            map.put("47", 2);
            map.put("13", 28);
            map.put("25", 17);
            int length =map.size();
            Collection<Object> c =map.values();
            Object[] obj=c.toArray();
            Arrays.sort(obj);
            System.out.println("获取Map中Value(值)的最小值======"+obj[0]);
            System.out.println("获取Map中Value(值)的最大值====="+obj[length-1]);
        }
    }

    获取Map中Value(值)的最小值======2
    获取Map中Value(值)的最大值=====28
  • 相关阅读:
    第四次作业
    第三次作业
    作业,11
    作业,10
    作业,9
    作业,8
    作业,7
    作业,6
    作业,5
    作业,4
  • 原文地址:https://www.cnblogs.com/xiaoniuniu886/p/11452047.html
Copyright © 2011-2022 走看看