I found out about this recently when I accidentally stumbled upon a response in the Java API. If you have ever had a card that uses enumerations as keys, make sure you use EnumMap . It is very simple and much more efficient:
public interface LibraryItem{ ... }
public enum LibraryItemType{ BOOK, CD, VHS, AUDIO; ... }
Map<LibraryItemType, NavigableSet<LibraryItem>> itemsByType =
new EnumMap<>(LibraryItemType.class);
source
share