Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.linkpendium.com!news.linkpendium.com!newsfeeds.ihug.co.nz!lust.ihug.co.nz!ihug.co.nz!not-for-mail From: Lawrence D'Oliveiro Newsgroups: comp.lang.java.programmer Subject: Re: Did the sort do anything? Followup-To: comp.lang.java.programmer Date: Fri, 20 May 2011 18:46:20 +1200 Organization: Geek Central Lines: 38 Message-ID: References: <9303hcFq0nU1@mid.individual.net> NNTP-Posting-Host: 118-92-95-178.dsl.dyn.ihug.co.nz Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Trace: lust.ihug.co.nz 1305873980 31548 118.92.95.178 (20 May 2011 06:46:20 GMT) X-Complaints-To: abuse@ihug.co.nz NNTP-Posting-Date: Fri, 20 May 2011 06:46:20 +0000 (UTC) User-Agent: KNode/4.4.7 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:4339 In message , Patricia Shanahan wrote: > On 5/17/2011 12:11 AM, Lawrence D'Oliveiro wrote: > >> In message, Patricia >> Shanahan wrote: >> >>> On 5/16/2011 2:11 PM, Lawrence D'Oliveiro wrote: >>> >>>> In message, Patricia >>>> Shanahan wrote: >>>> >>>>> System.identityHashCode(x) does not necessarily return the same as >>>>> x.hashCode() ... >>>> >>>> It says it does >>>> : >>>> >>>> The hash code returned is the same one that would be returned by >>>> the method java.lang.Object.hashCode(), whether or not the >>>> object's class has overridden hashCode(). >>> >>> My sample program output showed both x.hashCode() and >>> System.identityHashCode(x) for x referencing an Integer. The values were >>> different, because Integer overrides hashCode. >> >> How odd, because the above documentation says otherwise. >> > > The way I interpret it, and the way it works in practice, is that > System.identityHashCode(x) returns the value that would be returned by > x.hashCode() if the object referenced by x had inherited the Object > implementation of hashCode, regardless of whether x in fact uses an > overridden hash code. Ah. Fair enough.