0

Kotlin Enum examples

When we have a fixed set of predefined constants,  it is considered a good practice grouping them in an enum type.

Sample Usage

1. Simple Enum

Sample usage:

Outputs:

2. Enum with Instance Method and Field

Sample usage:

Outputs:

3. List all Enum types

Outputs:

References

https://kotlinlang.org/docs/reference/enum-classes.html

Karl San Gabriel

Karl San Gabriel

Java and Enterprise Technologies Expert