As we already have HashMap, why would we use EnumMap?
HashMap
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.
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.
1.4m articles
1.4m replys
5 comments
57.0k users