This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori 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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "equals()" Watch "equals()" New topic


sandhi mridul
Ranch Hand

Joined: Jan 25, 2008
Posts: 71

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

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

marc weber

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
I agree. Here's the link:
subject: equals()
It's not a secret anymore!