Browse topics
Object Oriented Kotlin
Objects & Enums
Object declarations, companion objects, expressions and enum classes.
kotlin objectsObject Declaration in Kotlinobject keyword creates a singleton instance. A Kotlin example with source code and sample output.kotlin objectsCompanion Object in KotlinCompanion object belongs to a class and acts like static members in Java. A Kotlin example with source code and sample output.kotlin objectsObject Expressions in KotlinObject expressions create anonymous objects on the fly. A Kotlin example with source code and sample output.kotlin objectsSingleton Pattern in KotlinSingleton ensures only one instance of a class exists. A Kotlin example with source code and sample output.kotlin objectsEnum Classes in Kotlinenum class represents a fixed set of constants. A Kotlin example with source code and sample output.
Related topics
Kotlin Classes Declare classes, properties, constructors and init blocks. Inheritance Open classes, overriding, abstract classes and inheritance rules. Interfaces Define and implement interfaces, functional interfaces and properties. Data Classes Data class declaration, copy, destructuring and equals/hashCode. Sealed Classes Sealed classes, when expressions and restricted type hierarchies.