Akshay Rawal wrote:
i am unable to get how values are retrieved using hashcode..somehow i was able to get answer..but it was guess..I am not sure correct way how get method finds value..
It would help if you tell us, what were the results, what were your guesses, and what is still confusing you. We can't read your mind, hence, we can't say if you are right or wrong.
Akshay Rawal wrote:
i am also unable to get..how this code when added at the end of main method produces following output
i just know use hashcode to find correct bucket and equals to find object.but practically how it works unable to get..
In this case, the key of a hashmap must not be mutated. If it is, the behavior is undefined (as it is a broken scenario). Since the behavior is undefined, we can't really say what should happen.
Henry