Meaningless Drivel is fun!*
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


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: 39084
    
  23
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: hash code equal method