posted 12 years ago
. . . and its hashCode method.
The hashCode method is used to decide which "bucket" the key-value pair is put into, and the equals() method is used to disambiguate pairs, in case there is more than one pair in a particular "bucket".If the JavaRanchUser class has an overridden equals() method [and hashCode()], that will print out NUISANCE. If the equals() method is not, however, overridden, the Map will not recognise the two keys as identical, and will return something else, and you will get a printout of "null". If the hashCode method is not overridden, the Map will not even find the correct "bucket".