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.
m.put(new Cat(), "Cat key");.
Neha Verma
Can somebody please explain-when Cat does not implement hashCode() then how are we able to get when we use m.get(c).
all events occur in real time
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 retrieving
stuff 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.)
all events occur in real time
all events occur in real time