About Question com.enthuware.ets.scjp.v6.2.759 :
Moderator: admin
About Question com.enthuware.ets.scjp.v6.2.759 :
The instructions on this question are less than helpful.
Re: About Question com.enthuware.ets.scjp.v6.2.759 :
It should be obvious that you have to provide a correct implementation of hashCode that meets the contracts of both equals and hashCode. It should be an automatic response to check for this.
The rule of thumb is that if a member is used in hashCode, it must be used in equals. The opposite is not true, however, as we see in this question.
The rule of thumb is that if a member is used in hashCode, it must be used in equals. The opposite is not true, however, as we see in this question.
-
- Posts: 5
- Joined: Sat Jan 10, 2015 10:27 am
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.759 :
I fully agree with the reply: if you use a member not used in equals, you are breaking the contract:if they are equal they should have the same hashcode, and if you use interests, they would be "equal" but with a different hashcode!!
Who is online
Users browsing this forum: No registered users and 4 guests