File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hashcode()?

 
Shyam Purkayastha
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
What is the use of hashcode() function?
Is it related to hashtable class ?
please help
 
Layne Lund
Ranch Hand
Posts: 3061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not completely sure, but I think you are on the right track. AFAIK, the HashTable and related classes from the Container API use the hashcode() function when it stores an object.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is used by any class that stores objects by using the hash code.
 
Jeremy Thornton
Ranch Hand
Posts: 91
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A hashcode is usually used as an efficient way of searching for stored objects.
Say you have a list of 1000 names, it would take a reasonable amount of time to search for the name "Jeremy Thornton" in the list.
If however you stored the names according to their hashed value (which is what the HashX type containers do) you just search for the hash of "Jeremy Thornton" - an integer - instead.
As integer processing is much faster than string processing the search is much quicker.
Hoper this helps,
Jeremy.
 
Shyam Purkayastha
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot jeremy
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic