Right, but the default implementation of hashCode() and equals() (as found in Object) are sufficient for the hash collections.  Specifically, hashCode() returns the class id and equals() performs “==” equality.

 

Kirk

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Alain Ravet
Sent: Thursday, February 21, 2002 5:59 AM
To: [EMAIL PROTECTED]
Subject: [Eap-features] OT: equals()/hashCode()

 

"Hani Suleiman"

> > What will be really fun is that, if you don't override equals() and
> > hashcode() when you should, java collections won't work as expected.
> >
> Uhm, no. Default implementation of equals is ==.
> ...

 

Uhm, no :

 

public class Hashtable

...
To successfully store and retrieve objects from a hashtable, the objects used as keys must implement the hashCode method and the equals method.

Reply via email to