posted 4 years ago
Hi Everyone,
I am not understands that how multiple values or objects can associate with one key in HashMap.
I have tried below example,
Output :
Map : {emp1=Employee [id=1, name=Anand, city=Pune]}
Map : {emp1=Employee [id=1, name=KKC, city=Pune]}
Can you please explain me the output and how hascode and equals has worked here, as if I comment the overridden hascode and equals methods still the output is the same so confused in hashcode equals contract.
Thank you in advance.