Kotlin 2 · Classes and types
Classes and constructors
The primary constructor is part of the class header. Properties can have getters.
class Account(val owner: String, balance: Int = 0) {
var balance = balance
private set
fun deposit(amount: Int) { balance += amount }
}
Official Kotlin 2 documentation