Kotlin allows classes to be declared inside the body of another class. Other modern OO languages also allow this, and these kinds of classes are usually called nested or inner classes. Here's an example of how you would declare a nested class:
class User(val name: String) {
class Address(val street: String,
val streetNumber: String,
val zip: String,
val city: String)
}
And if you'd like to instantiate the Address class, you would have to do it like this, prefixing the containing class first:
val address = User.Address("Aparo Park", "1", "ABC", "Gotham City")
Visibility modifiers can be applied to nested classes as well. Here's the same example, but this time the nested class is private:
class User(val name: String) {
private class Address(val street...