[jdom-interest] Namespace.hashcode patch

Bryan Thale thale at labs.mot.com
Wed May 30 19:12:28 PDT 2001


philip.nelson at omniresources.com wrote:

> I assume, and I will be satisfied to be wrong here, that hashcode and ==
> have to mean the same thing, an object instance.  .equals() can have a
> different meaning though one would avoid it given a reasonable option.

I don't think hashCode() has anything to do with ==.  It is perfectly legal for two
unequal objects (i.e., !ns1.equals(ns2)) to return the same result from hashCode().
The requirement is only that if two objects are equal according to the equals()
method then hashCode() must return the same value for both objects.  That is, it is
a hash.  Hopefully the hash values are sparse and no two immediately available
unequal objects share a value, but the hash doesn't guarantee it.

Bryan.

--
Bryan Thale
Motorola Labs, Networking and Infrastructure Research
mailto:thale at labs.mot.com






More information about the jdom-interest mailing list