public class MapMinMaxvalue {
public static void main(String[] args) {
Map map=new HashMap();
map.put("2", 5);
map.put("47", 2);
map.put("13", 28);
map.put("25", 17);
int length =map.size();
Collection 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