hashcode

hai what is the use of hashcode function?
[48 byte] By [rocky_navasa] at [2007-10-3 4:30:22]
# 1
To get the hashcode for an object.
cotton.ma at 2007-7-14 22:33:36 > top of Java-index,Java Essentials,Java Programming...
# 2

Hashcodes can be used in various algorithms and data structures, in particular hash tables.

If you create a class, you should always make sure that the hashCode and equals methods make sense for that class. Joshua Bloch wrote a chapter in his book Effective Java that goes into wonderful detail about this. The chapter is available on this site somewhere as a pdf. Try googling for it, maybe with a search like this:

joshua bloch effective java hashcode filetype:pdf site:java.sun.com

Everyone should learn about the filetype: and site: search modifiers on Google. They're wonderful.

Ah, here it is:

http://java.sun.com/developer/Books/effectivejava/Chapter3.pdf

paulcwa at 2007-7-14 22:33:36 > top of Java-index,Java Essentials,Java Programming...
# 3
Anticipating the next question, and assuming agoolglia: http://en.wikipedia.org/wiki/Hash_code
pbrockway2a at 2007-7-14 22:33:36 > top of Java-index,Java Essentials,Java Programming...