tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: [OT] Hi Guys ... can some one tell what is hashcode in java
Date Wed, 15 Sep 2010 22:08:00 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ramzi,

On 9/15/2010 12:43 PM, ramzi khlil wrote:
> HashCode is a value computed in such way to be unique as possible to improve
> performance while retrieving object in HashedCollections.

What are HashedCollections?

> If for example you have a HashMap, and didn't overrride hashCode() method
> all your objects will be in the same bucket resulting a slow execution while
> retrieving an object.

Wow. That is so wrong.

> But if you do provide an efficient implementation of hashCode() method your
> objects will be stored across many buckets

This is also not correct.

> and you look up for one of them,
> the api does calculate the hashCode of your object and then it selects the
> right bucket.

Actually, it calls the hashCode method on the object that requires it.
The API performs no calculations. (Technically speaking, the API doesn't
do anything but exist, but let's not pick nits).

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkyRQ78ACgkQ9CaO5/Lv0PDpkACcDvP2LPw13oXupFptDFRikrDm
YNEAn39YX7/mkXsAu/fOSWsAETNYxAsZ
=igRA
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message