This week's book giveaways are in the iOS and Features new in Java 8 forums.
We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes hash code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "hash code" Watch "hash code" New topic
Author

hash code

kooskuntla venkat
Greenhorn

Joined: Sep 10, 2005
Posts: 11
what is a hashcode? give an example
Sravan Kumar
Ranch Hand

Joined: Sep 11, 2005
Posts: 121
Check this out.


keep smilin :: sravan<br /><a href="http://sravanpens.blogspot.com" target="_blank" rel="nofollow">I scribble here</a>
Rick O'Shay
Ranch Hand

Joined: Sep 19, 2004
Posts: 531
A hash code is a number, period. It's whatever you say it is. Hash code functions are either good or bad. If you take input data and generate a number from that data using an algorithm of your choosing, you have a hash code.

Here is a hash function for string data that returns a hash code:

int hash(String data) { return 0; }

Note that it returns the same value no matter what. This is the worst kind of hash function.

Here's another bad one. It adds all the characters in the string. Alice would generate the same value as Aceli or Aleic. Duplicates are allowed, however, the more you have the worse your hash function.



(sadly, strings cannot be iterated it's the idea that's important here not writing a valid hash code method)
[ September 16, 2005: Message edited by: Rick O'Shay ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: hash code