HashMap<Integer,Long> hm1=new HashMap();
hm1.put(1, 5l);
hm1.put(2, 6l);
HashMap<Integer,Short> hm2=new HashMap(hm1);
hm2.put(3, (short) 0);
System.out.println(hm2);
去看看 HashMap 深浅拷贝 对你也许有不错的提升 :)
value字段只是表示了存储的值的类型,你long跟Short之间可以帮你做转换。