KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I always thought that enum hashCode was referring to ordinal in Java, since ordinal seems to be a perfect candidate for hashCode , but it turns out it enum hashCode actually refers to default hashCode object implementation. I understand, that this does not contradict JLS , but still this came to me as a surprise, and I can't think why it was made this way. Although I guess JVM , could have relied on this somehow to provide unique guarantees, but this does not hold anymore for 64 bit JVM . I've checked in JDK 1.6, and latest JDK 7, and this is the same way in both. Does any one know reason why, it was made this way? It makes a perfect sense to use ordinal as a hashCode , since it satisfies all the credentials needed plus it is even consistent from one JVM start to the other, which is not required, but nice thing to have.
Tags (comma-separated)
Save Edits
Cancel