wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes interdependence of equals() and hashCode() 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 » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "interdependence of equals() and hashCode()" Watch "interdependence of equals() and hashCode()" New topic
Author

interdependence of equals() and hashCode()

Barkat Mardhani
Ranch Hand

Joined: Aug 05, 2002
Posts: 787
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

Joined: Apr 24, 2003
Posts: 24
Hi Barkat,
It does not get mentioned in equals() contract becuase it belongs to hashCode() contract.
Alex

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: interdependence of equals() and hashCode()
 
Similar Threads
difference between !=(Not equal) and ^(XOR)
hashCode(), compareTo() and equals()
how does equals() work with lists as objects?
Related to String
Mock doubt, a Q about equals contract