• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

hashCode() method

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi guys,
what is purpose of hashCode() method? In which type of programs we can use it? can u explain it with example...I didn't found any example that will help me to understand this topic in detail.

please.....help me......
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HashCode is a function used in hash tables.

You can see this for a good example and explanation : http://www.sparknotes.com/cs/searching/hashtables/section1.html

In Java, hash tables are used for HashSet, HashMap, ...

The hashCode() function need to be defined in objects you want to store in a collection implementing a hash table, such as HashSet, ...

For a good way to implement hashCode(), you should look at Effective java Programming Language Guide, Item 8.

For a tutorial on Collections in Java, you can look at : http://java.sun.com/docs/books/tutorial/collections/index.html
reply
    Bookmark Topic Watch Topic
  • New Topic