j.l.r.Parameter.hashCode() question
Joe Darcy
joe.darcy at oracle.com
Mon Oct 28 09:41:27 PDT 2013
On 10/28/2013 08:55 AM, elena votchennikova wrote:
> Hello Joe,
>
> On 25.10.2013 21:11, Joe Darcy wrote:
>>
>>>
>>>>> On 04.10.2013 5:03, Joseph Darcy wrote:
>>>>>> The phrased "based on" means "some unspecified function of."
>>>>>
>>>>
>>>
>> I don't really see how the equals contract saying "Compares based on
>> the executable and the index" could lead a reasonable programmer to
>> code up something that was not equivalent to
>> "other.executable.equals(executable) && other.index == index".
>>
>
> "Compares based on the executable and the index" means
> someFunction(Executable executable, int index, ???)
>
> I cannot say nothing about the implementation of this "someFunction".
>
>
If on an exam you were posed the question:
"Equality for the Parameter class compares on the executable and the
index. Write an equals method for the Parameter class that satisfies the
general equals contract."
and you answer did not include something like
...
return this.executable.equals(that.executable) && this.index ==
that.index
your answer would be marked wrong. There is no other way to satisfy the
constraints of the problem.
-Joe
More information about the enhanced-metadata-spec-discuss
mailing list