• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

equals()

 
sandhi mridul
Ranch Hand
Posts: 71
  • 0
  • 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
  • 0
  • 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?
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic