Why string is popular hashmap key in java?



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

Post New Answer

More Core Java Interview Questions

how can we use the servlet as standalone apllication?should we need to extend any class?

2 Answers   Logica CMG,


How do I find and replace in word?

0 Answers  


What is the string function?

0 Answers  


Why all programming languages have main as a execution starting point?

4 Answers  


Which is dependent variable?

0 Answers  






When can you say a graph to be a tree?

0 Answers   Amazon,


How does linkedlist work in java?

0 Answers  


What is thread pool in java with example?

0 Answers  


Nullpointer exception is a very common exception. Why is it not made as a checked exception?

2 Answers   Ness Technologies,


What is a layout manager?

1 Answers  


What is an argument in java?

0 Answers  


What is the method overriding?

0 Answers  


Categories