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 |
List methods available in Java Queue interface
Differentiate between the constructors and methods in java?
Can we declare main () method as non static?
How can a class be accessed, If no access modifiers are declared?
What is a memory leak in java?
Can we instantiate interface in java?
What is java util?
Can we initialize the final blank variable?
what is a thread?
What are static variables and functions?
What is the difference between overriding & overloading?
What defines function?