Objects & Enums
Object declarations, companion objects, expressions and enum classes.
1
kotlin objects
2Object Declaration in Kotlin
object keyword creates a singleton instance. A Kotlin example with source code and sample output.
kotlin objects
3Companion Object in Kotlin
Companion object belongs to a class and acts like static members in Java. A Kotlin example with source code and sample output.
kotlin objects
4Object Expressions in Kotlin
Object expressions create anonymous objects on the fly. A Kotlin example with source code and sample output.
kotlin objects
5Singleton Pattern in Kotlin
Singleton ensures only one instance of a class exists. A Kotlin example with source code and sample output.
kotlin objects
Enum Classes in Kotlin
enum class represents a fixed set of constants. A Kotlin example with source code and sample output.