J
Jean Lutrin
Hi everybody,
thanks a lot for all the answers, it helped me a lot.
A Set is indeed a more correct abstraction than a Map (even
if, say, an HashSet is implemented using an HashMap).
What I didn't realize was that .equals() and .hashcode() were
supposed to be consistent (I say "supposed" because there's no
doubt that some programmers forget to comply with this rule).
For whatever reason I was thinking that the hash value was
generated from the reference of the object, which was of
course completely false.
As a funny side note, it means the way I solved my problem
while thinking I was wrong is actually correct
Thanks a lot for all your answers,
Jean
thanks a lot for all the answers, it helped me a lot.
A Set is indeed a more correct abstraction than a Map (even
if, say, an HashSet is implemented using an HashMap).
What I didn't realize was that .equals() and .hashcode() were
supposed to be consistent (I say "supposed" because there's no
doubt that some programmers forget to comply with this rule).
For whatever reason I was thinking that the hash value was
generated from the reference of the object, which was of
course completely false.
As a funny side note, it means the way I solved my problem
while thinking I was wrong is actually correct
Thanks a lot for all your answers,
Jean