java - Why it is necessary to override hashcode and equals method of key for Hashmap? -
this question has answer here:
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
Comments
Post a Comment