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

What is anagram in java?

0 Answers  


What happens when a thread cannot acquire a lock on an object in java programming?

0 Answers  


Can you run the product development on all operating systems ?

1 Answers  


What are assembly attributes?

0 Answers  


What does int argc char * argv [] mean?

0 Answers  






What is the type of lambda expression?

0 Answers  


while creating thread why we extend thread class

2 Answers  


What is an accessor?

1 Answers   BirlaSoft,


Are arrays primitive data types?

0 Answers  


How do you replace a string in java?

0 Answers  


Which methods are used during serialization and deserialization process?

0 Answers  


What is bubble sort in java?

0 Answers  


Categories