Java code to Prevent duplicate pairs in HashMap/HashTable

前端 未结 7 2075
梦谈多话
梦谈多话 2021-01-17 02:32

I have a HashMap as below (assuming it has 10,0000 elements)

HashMap hm = new HashMap();
hm.put(\

7条回答
  •  孤独总比滥情好
    2021-01-17 03:02

    if(hm.put("John","1") != null)
    {
      // "John" was already a key in the map.  The sole value for this key is now "1".
    }
    

提交回复
热议问题