sに関する調査を行っていMap
たところ、同じキーを意図的に 2 回追加すると、Map のサイズは同じままになることがわかりました。この背後にある技術的な理由は何ですか?
Map map=new HashMap();//HashMap key random order.
map.put("Amit","Java");
map.put("Amit","Java");
取得するコード...
System.out.println("There are "+map.size()+" elements in the map.");
System.out.println("Content of Map are...");
Set s=map.entrySet();
Iterator itr=s.iterator();
while(itr.hasNext())
{
Map.Entry m=(Map.Entry)itr.next();
System.out.println(m.getKey()+"\t"+m.getValue()+"\t"+ m.hashCode());
}
私が得る結果:
There are 1 elements in the map.
Content of Map are...
Amit Java 3943477