• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

hashCode()

 
Ranch Hand
Posts: 528
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
The first person to drink cow's milk. That started off as a dare from this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic