我试图用一种用法初始化:为什么HashMap中的散列码是零
Map<String, String> mapInter = Collections.EMPTY_MAP;
mapInter = new HashMap<String, String>();
mapInter.put("one", "one");
System.out.println(mapInter.hashCode());
方法有两个:
HashMap<String, String> myMap = new HashMap<String, String>(10);
myMap.put("key", "value");
System.out.println(myMap.hashCode());
在第一种方法,当我打印的哈希码是打印为零,但在第二种方法是打印哈希码。初始化后的hashcode将被返回。
为什么第一个Case中的HashCode打印为零,但不是第二种情况?
最新问题? – Khashayar
你有什么要求?我无法理解。 初始化一个地图只是做一个新的HashMap() –
方法三: Map myMap = new HashMap (10); –