• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

interdependence of equals() and hashCode()

 
Barkat Mardhani
Ranch Hand
Posts: 787
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if x.equals(y) is true, then x.hashCode() == y.hashCode()must be true.
If the above statement is true, why is that contract of equals method does not mention this requirement?
Thanks
Barkat
 
Alex Radomski
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Barkat,
It does not get mentioned in equals() contract becuase it belongs to hashCode() contract.
Alex

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic