Java code to Prevent duplicate pairs in HashMap/HashTable

前端 未结 7 1955
梦谈多话
梦谈多话 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:05

    I note that you clarify the question by suggesting you might have "100000000 elements". You still won't have duplicates in the HashMap, because, as two other posters have pointed out, you can't get duplicate keys in a Map. I'm still not sure we understand the question, though, as it's not at all clear how you expected to generate the block titled "Output", or what you intend to do with it.

    0 讨论(0)
提交回复
热议问题