Enum Hash Codes Are Non-Deterministic
An annoying discovery: Java Enum
objects have non-deterministic hash codes. Specifically, a hash code is the Enum
's identity (or memory address).
public final int hashCode()
{
return super.hashCode();
}
So, should you ever make the same mistake as me, keying a HashMap
with an Enum
, strongly consider using EnumMap
, instead.