Kotlin Classes
Declare classes, properties, constructors and init blocks.
Class Declaration in Kotlin
A class is a blueprint for creating objects. A Kotlin example with source code and sample output.
Class Properties in Kotlin
Properties store state inside a class. A Kotlin example with source code and sample output.
Class Constructors in Kotlin
Constructors initialize object properties when an object is created. A Kotlin example with source code and sample output.
Primary Constructor in Kotlin
Primary constructor is part of the class header. A Kotlin example with source code and sample output.
Secondary Constructor in Kotlin
Secondary constructors are declared inside the class body using constructor keyword. A Kotlin example with source code and sample output.
init Block in Kotlin
init block contains initialization code for a class. A Kotlin example with source code and sample output.
Nested and Inner Classes in Kotlin
A nested class is declared inside another class and does not hold a reference to the outer instance. A Kotlin example with source code and sample output.
Custom Getters and Setters in Kotlin
Properties can define custom get and set logic while keeping field-like syntax. A Kotlin example with source code and sample output.