What made me think that `Enum.foo` would sometimes...
# announcements
l
What made me think that
Enum.foo
would sometimes be differente from
Enum.foo
, and that's impossible?
c
in JVM spec hashCode for an instance has only to be the same during specific execution of the application.
equals
therefore must not use
hashCode
. If equals is implemented correctly
MyEnum.foo
always equals
MyEnum.foo
l
I thought that by spec, if a value is equal to another via equals, their hashcodes must always be the same
c
right, I've said a bit of a rubbish there, the text that is not strike-though though is still true and that's why it's ok that the objects are different 🙂
d
It's stil strange though, it seems it's not entirely random, but chooses 1 of 2 values, not sure how that's determined though