In this chapter, you will learn
- What enum types are
- How to declare enum types and enum constants
- How to use enums in switch statements
- How to associate data and methods to enum constants
- How to declare nested enums
- How to implement interfaces to an enum type
- How to perform a reverse lookup for enum constants
- How to use EnumSet to work with ranges of enum constants
What Is an Enum Type?
An enum (also known as enumeration and enumerated data type) lets you create an ordered list of constants as a type. Before we discuss what an enum is and why we need it, let’s consider a problem and solve it using Java features that were ...