wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets 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: 37953
    
  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?
 
jQuery in Action, 2nd edition
 
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