Selasa, 27 Juli 2021

How to use EnumSet in Java with Example

EnumSet is one of the specialized implementations of the Set interface for an enumeration type, introduced in Java 1.5 along with the enumeration type itself. Programmer often stores Enum into common collection classes e.g. HashSet or ArrayList, mostly because they are unaware of this little gem. Even I wasn't aware of this class a few years ago until I come across one of the finest books for Java programmers, Effective Java. It has an Item on EnumSet, which highlights some typical use-cases for this collection class instead of using int variable and bitwise operator. Since Enum constants are unique and have pre-defined lengths, as you can not define a new enum constant at runtime; it allows Java API designers to highly optimize EnumSet.

Lorem ipsum is simply dummy text of the printing and typesetting industry.

Comments


EmoticonEmoticon