Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!novia!news-out.readnews.com!transit3.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!53ab2750!not-for-mail From: "Roedy Green" Subject: Re: hashCode Message-ID: <50269FD1.56651.calajapr@time.synchro.net> X-Comment-To: Lew Newsgroups: comp.lang.java.programmer In-Reply-To: <50269FCD.56633.calajapr@time.synchro.net> References: <50269FCD.56633.calajapr@time.synchro.net> X-FTN-AREA: COMP.LANG.JAVA.PROGRAMMER X-FTN-MSGID: 1:261/38 8dbf78a7 X-FTN-REPLY: 1:261/38 834ffa64 Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.16a-Win32 NewsLink 1.98] Lines: 24 Date: Sat, 11 Aug 2012 18:17:54 GMT NNTP-Posting-Host: 69.21.70.65 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1344709074 69.21.70.65 (Sat, 11 Aug 2012 13:17:54 CDT) NNTP-Posting-Date: Sat, 11 Aug 2012 13:17:54 CDT Organization: tds.net Xref: csiph.com comp.lang.java.programmer:17703 To: Lew From: Roedy Green On Fri, 10 Aug 2012 12:45:07 -0700 (PDT), Lew wrote, quoted or indirectly quoted someone who said : > h =3D 31 * h + attribute.hashCode(); > } In my essay I recommend XOR which is an inherentely faster operation than multiply. I wonder which actually works out better. If you had a large number of fields, the multiply effect could fall off the left hand end. It is the algorithm used for String which could have very long strings, so Sun must have thought of that. -- Roedy Green Canadian Mind Products http://mindprod.com A new scientific truth does not triumph by convincing its opponents and making them see the light, but rather because its opponents eventually die, and a new generation grows up that is familiar with it. ~ Max Planck 1858-04-23 1947-10-04 --- BBBS/Li6 v4.10 Dada-1 * Origin: Prism bbs (1:261/38) --- Synchronet 3.16a-Win32 NewsLink 1.98 Time Warp of the Future BBS - telnet://time.synchro.net:24