EnumSet

EnumSet can contain elements from a certain enumeration. Recall that enumerations are classes that have fixed a number of instances declared inside the enum itself. As this limits the number of the different object instances, and this number is known during compilation time, the implementation of the EnumSet code is fairly optimized. Internally, EnumSet is implemented as a bit field and is a good choice where bit field manipulations would be the choice were we programming in a low-level language.

Get Java Projects - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.