Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

equals()  RSS feed

 
sandhi mridul
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!