+ 2

When to use hashMap

i know hashMap,but i dont know in which type of problem should be used

26th Nov 2017, 4:54 PM
allahnoor turab
allahnoor turab - avatar
1 Answer
+ 13
It's useful when you need a dictionary-like key-value pair mapping which enable us to find the corresponding value with a unique key. You may think it can be solved by defining our own class as well but the advantage is performance boost due to the hash applied to the key for faster retrieval. Just imagine the hashes are the table of content/appendix in the dictioanry, it allows faster lookup based on the keyword. However, do notice that the order of HashMap provides no guarantee. 😉
26th Nov 2017, 11:43 PM
Zephyr Koo
Zephyr Koo - avatar