Kotlin Classes
A Kotlin class can declare its properties right in the primary constructor. val makes a read-only property and var a mutable one, and marking it private hides it from code outside the class.
Kotlin
class Account(val owner: String, private var balance: Int) {
fun deposit(amount: Int) {
balance += amount
}
fun report(): String = "$owner has $balance"
}
fun main() {
val account = Account("Ada", 100)
account.deposit(50)
println(account.report())
}