classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: hashCode question (was Re: Silly Java question)


From: Michael Barker
Subject: Re: hashCode question (was Re: Silly Java question)
Date: Wed, 28 Dec 2005 19:55:27 +0000

On Tue, 2005-12-27 at 10:26 -0800, Per Bothner wrote:
> Michael Barker wrote:
> > Given that the toString() must be the same in order to be equal
> 
> Huh?  I don't believe there is any such requirement.  One would
> normally expect toString to match for equal objects, but it is
> not required.  Atter all, the default toString will not satisfy
> this requirement if equals has been redefined.  And I often put
> in a sequence number in the toString result, for debugging.

>From the equals() code, its applicable in this case:

    // The toString output must match.
    if (! toString().equals(((KerberosPrincipal)that).toString()))
      return false;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]