why string is popular hashmap key in java 3f

Solutions on MaxInterview for why string is popular hashmap key in java 3f by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "why string is popular hashmap key in java 3f"
Matilda
23 Jul 2018
1Since 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.