Enums Flashcards
An enum is
A special class that represents a group of constants (unchangeable variables like ‘final’)
Enums should be in
Uppercase letters
enum Level = {
LOW,
MEDIUM,
HIGH
}
Enum is short for
Enumeration which means specifically listed
You can access enums with
The dot notation
Eg Level mylar = Level.MEDIUM
The enum has a values() method which returns
An array of all enum constants
The enum method is useful when you
Want to loop through the constants of an enum
An enum can just like a class have attributes and methods. The only difference is that the enum constants are
Public, static and final
An enum cannot be used to
Create objects
An enum cannot be used to extend other classes but can
Implement interfaces