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 |
How does arraylist work in java?
What is empty string literal in java?
How to create an instance of a class if the class has private constructor?
what do you meant by Runtime Polymorphism?
13 Answers BVIMR, IBM, Persistent,
What is the purpose of final keyword and when to use it?
What are assertions in java?
What is native code?
What is core java called?
What is local class in java?
What is final keyword?
How does arraylist size increase in java?
How many types of gc are there in java?