Let’s break it down simply 👇
✅ What is Enum Class in Kotlin?
An enum class (short for enumeration class) is a special type of class in Kotlin used to
represent a fixed set of constants.
It’s helpful when a variable can only take one value out of a limited set of predefined options.
📌 Syntax:
enum class Direction {
NORTH, SOUTH, EAST, WEST
Here, Direction is an enum class that has four constant values.
🎯 Uses of Enum Class:
1. Type-Safe Constants – Ensures only valid values are used (unlike plain strings or
integers).
2. Improves Code Readability – Groups related constants together.
3. Supports Properties & Methods – Each enum constant can have its own data or
behavior.
4. Useful in Control Flow (when statements) – Easy to handle different cases.
5. Prevents Invalid Inputs – You cannot pass values outside the enum set.
📌 Example:
enum class Day {
MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY
fun main() {
val today = Day.MONDAY
when (today) {
Day.MONDAY -> println("Start of the week")
Day.FRIDAY -> println("Weekend is near!")
Day.SATURDAY, Day.SUNDAY -> println("It’s Weekend 🎉")
else -> println("Midweek Day")
👉 Output:
Start of the week
Would you like me to also create a short PDF file for this explanation (like the one you asked
earlier) so you can keep it as notes?