This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes equals() 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 "equals()" Watch "equals()" New topic
Author

equals()

sandhi mridul
Ranch Hand

Joined: Jan 25, 2008
Posts: 71
hi,



put the correct implementation of hashcode() at line 1.
ans-
return o;
return a+b;
return a^b;

I am not at all getting what is going on in the above code.
need help.

Thanks
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

The "hashcode contract" defines a relationship between hashCode and equals. This contract is described in the API under the hashCode method of Object.

So the question here is: Given the equals method in this code, what implemention(s) of hashCode would fulfill the contract?

Does that help?


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: equals()
 
Similar Threads
equals and hashcode
Khalid Mock - Hashcode Q
Strings
Overriding equals() and hashCode() methods
Question on hashCode implementation