java - Why it is necessary to override hashcode and equals method of key for Hashmap? -


i created hashmap having student key , string value.

now everywhere have read necessary override equals , hashcode method if using key hashmap.

but did not override it. , insert multiple key value pairs in hashmap. able fetch back.

so why necessary?

they required when want use objects useful hashing keys collections use hashing.

have tried add student objects meaningfully equal? first understand significance of equals method in java

read significance of equals , hashcode


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -