Enum
giving meaningful names to not-meaningful numbers
Enumeration
Enumeration (aka Enum): User-defined data type for assigning names to constants, so the code becomes more legible.
We will use
UPPER_SNAKE_CASE
most of the time for enums.
Sample Code
Output:
You can also declare enum variables.
Sample Code
Output:
Enums are useful when we want to define multiple variables which can be grouped together.
Last updated