As we already have HashMap
, why would we use EnumMap
?
The Javadoc makes a pretty good argument:
Enum maps are represented internally as arrays. This representation is extremely compact and efficient.
Implementation note: All basic operations execute in constant time. They are likely (though not guaranteed) to be faster than their HashMap counterparts.