This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hash code equal method

 
jacob deiter
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This article does a good job of explaining equals() and hashCode().
 
Bhagat Singh Rawat
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at equals() and hashCode()
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic