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 difference between hashset and treeset in java?
Can we have 2 main methods in java class?
What is generic type?
What are listeners in java and explain ?
What is meant by main method?
Explain the term serialization?
what is the difference between pagecontext and servletcontext?
diff between abstract methods and interfaces with programing (code) example?
Which is better list or arraylist in java?
Is there memory leaks in java?
What are drawbacks of singleton class?
What is encapsulation? Elaborate with example?