Answers for "Why String is popular HashMap key in Java?"

0

Why String is popular HashMap key in Java?

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 key in a Map and its processing is fast than other HashMap key objects. This is why String is mostly used Object as HashMap keys.
Posted by: Guest on September-01-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language