• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hashCode()

 
Marcelo Ortega
Ranch Hand
Posts: 528
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please correct me if i am wrong, but the hashCode method is supposed to generate an integer value which is used to IDENTIFY buckets in a Hashtable or a Map in general? Or is it the key which is used to locate the buckets?

i'm reading it in books but am having abit of trouble, can someone plz explain this to me in THEIR OWN words. Thanks for your time.

Cheers, Marzo.
 
Marcos Vilela
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The hashcode generate an int that identify in which bucket the object will be and if there are more then one object in the bucket, you are going to use the equals method to find the exactly object that you are looking for.

Correct me if I'm wrong..
Thanks.
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Marcos Vilela:
Correct me if I'm wrong..


That is correct, Marcos.

If you're interested, I wrote an article once upon a time regarding Hash Codes. You can find it here. Hopefully, that will help answer any questions you have and, if not, ask some more.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic