This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes hash code equal method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "hash code equal method" Watch "hash code equal method" New topic
Author

hash code equal method

jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
It is common understanding that if Equal method of a Java class overridden then Hash code method should be overridden

1) any one explain why it so?

2) What happen if overridden one method (Ex:hash code) and not overridden the second method?

3) what is the real use of hash code in java?.Is it have any importance in hash map?
W. Joe Smith
Ranch Hand

Joined: Feb 10, 2009
Posts: 710
This article does a good job of explaining equals() and hashCode().


SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
Bhagat Singh Rawat
Ranch Hand

Joined: Apr 04, 2009
Posts: 93
Look at equals() and hashCode()


Brainbench Java 2.0 Fundamentals, J2EE 1.4
http://www.brainbench.com/transcript.jsp?pid=8192792
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38045
    
  22
jacob deiter wrote:2) What happen if overridden one method (Ex:hash code) and not overridden the second method?

3) what is the real use of hash code in java?.Is it have any importance in hash map?
Have you tried it?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: hash code equal method
 
Similar Threads
what is contract between equal and hash code
Doubt: equals() & hashcode() method
legal but not correct equals( )
Regarding Hashcode