470,870 Members | 1,396 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,870 developers. It's quick & easy.

How do you compute Hashcode in Java ?

Hi,
Just wondering what's the algo used to compute hashcode in Java ? Does
anybody here know ?

Thanks,
-MK.
Jul 17 '05 #1
1 6677
On 10 Aug 2004 19:29:59 -0700, pentium77 wrote:
Just wondering what's the algo used to compute hashcode in Java ? Does
anybody here know ?


Read the documentation for Object.hashCode().

There is no single algorithm for computing hashcodes, it depends on
what your data consists of. You most likely don't use the same
algorithm to compute the hashcode of an Integer and an EmployeeRecord.

The important details are that the hashcode for an object cannot
change, and that two objects that are equal must have the same
hashcode (that doesn't mean that objects that are not equal must have
different hashcodes, although that is usually desireable).

/gordon

--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Nick | last post: by
3 posts views Thread by Josema | last post: by
1 post views Thread by Frank | last post: by
8 posts views Thread by MuZZy | last post: by
9 posts views Thread by archana | last post: by
madhoriya22
11 posts views Thread by madhoriya22 | last post: by
1 post views Thread by praveenkumarvpk | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.