posted 20 years ago
Welcome to the Ranch Yasin.
Hastable API says:
To successfully store and retrieve objects from a hashtable, the objects used as keys must implement the hashCode method and the equals method.
The Map interface adds:
Note: great care must be exercised if mutable objects are used as map keys. The behavior of a map is not specified if the value of an object is changed in a manner that affects equals comparisons while the object is a key in the map. A special case of this prohibition is that it is not permissible for a map to contain itself as a key. While it is permissible for a map to contain itself as a value, extreme caution is advised: the equals and hashCode methods are no longer well defined on a such a map.
SCJP2. Please Indent your code using UBB Code