posted 14 years ago
I am really confused about how HashMaps work. According to the code below, two instances of Dog are equal if they share the same name, and the hashcode has been overridden as well.
My question is - when I try to use d3 as a key, why do I get null as the value?? Since d3.equals(d2) returns true , and their hashcode are equal -shouldn't the value for d3 be "Dog2" (like it is for d2)?
What am I doing/understanding wrong?
Thank You.