Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Diff between Hashcode and equals

 
Chandra Bairi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following statements are true about correctly overriden hashCode() and equals() methods?

1) the equals() must return the same value as using the == operator
2) equals() and hashCode() code must return the same value.
3) If two objects are different according to equals() they will return different hashCode() values.
4) If two objects are equal according to equals() they will return the same hashCode value.

Kindly let me know the correct answer
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
4
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic