Why string is popular hashmap key in java?
Answer / vishalshetkar
Since String is immutable, its hashcode is cached at the time of creation and it doesn’t need to be calculated again. This makes it a great candidate for keys in a Map and its processing is fast than other HashMap key objects. This is why String is mostly used Object as HashMap keys.
Is This Answer Correct ? | 0 Yes | 0 No |
What is the driver class?
What is the purpose of the strictfp keyword?
What is the this keyword?
Which of these methods belong to Thread & Object class? join, yield, sleep, wait, notify
Why is serialization required?
When should the method invokelater() be used?
What is variable declaration and definition?
List interface?
What is finalize()?
How do you take thread dump in java?
I want to persist data of objects for later use. What is the best approach to do so?
What is the purpose of void class?