In K&B at page 563 : "Remember that when you use a class that implements Map, any classes that you use as a part of the keys for that map must override the hashCode() and equals() methods. (Well, you only have to override them if you're interested in retrievingstuff from your Map. Seriously, it's legal to use a class that doesn't override equals()and hashCode() as a key in a Map; your code will compile and run, you just won't find your stuff.)"
In the code below : The Cat class doesn't override hashCode() and equals() but still able to retrieve(find) the stuff. It's it a contraction to k&B statement?
Here, We want to get the meaningfully equal Cats(c1,c2 are equal in our sense) String that is "A".But this not catching the Cat That have a name as "B",but referring another Cat.So, the Item to the corresponing to the given key is not there(According to JVM),then surely the answar will be null. Best example given by-- wise owen,Thank you.
subject: hashCode() and equals() - How it is possible