Skip to content

Replicating the enum functionality using sealed classes

Devrath edited this page Aug 9, 2022 · 1 revision

This is highly unlikely since we use an enum instead of sealed class for this requirement

Enum representation

enum class Student {
    Mahesh,
    Suresh,
    Smitha
}

SealedClass representation

sealed class Student {
    object Mahesh
    object Suresh
    object Smitha
}
Clone this wiki locally