Kotlin Nested and Inner Classes, Anonymous Objects, and Enum Classes
Kotlin supports nesting classes within other classes. A nested class is declared directly enside another class and does not hold a reference to a instance of the outer class:
class Outer {
private val value = 1
class Nested {
fun getValue() = 2
}
}
val result = Outer.Nested().getValue() // Returns 2
When a nested class is ...
Posted on Sun, 10 May 2026 12:35:52 +0000 by alex_lana