Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!216.196.98.146.MISMATCH!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Tue, 17 May 2011 08:56:34 -0500 Date: Tue, 17 May 2011 06:56:28 -0700 From: Patricia Shanahan User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Did the sort do anything? References: <9303hcFq0nU1@mid.individual.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 33 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 75.8.126.96 X-Trace: sv3-D4VZMCzsj+zQMWpVFHemDnp9IVsBNaMRbEe1tlonHYefMH0tZehEmI5uYjnlzB+LTbJ6M7Jo93rELZo!2b9NEDtI9eRRB58x+YloOoLbJ6ye0sQ5BfPipnZSNouFyGRNn+RKY2weIadIKfjys4mufA5r24dq!bR3WC9knz6SNzjnsKvWb3V6fuKeXfUcNuel6Orqe/PE= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2900 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:4212 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. > Now that we have clarified the fact that System.identityHashCode(x) is not merely a synonym for x.hashCode(), have you changed your mind about the need, or otherwise, for stability when sorting Java objects based on the entire value of the object's fields? Patricia