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 anagram in java?
What happens when a thread cannot acquire a lock on an object in java programming?
Can you run the product development on all operating systems ?
What are assembly attributes?
What does int argc char * argv [] mean?
What is the type of lambda expression?
while creating thread why we extend thread class
What is an accessor?
Are arrays primitive data types?
How do you replace a string in java?
Which methods are used during serialization and deserialization process?
What is bubble sort in java?