Variables are used to store data values in Kotlin. You can declare them using val
(immutable) or var
(mutable).
val
— Read-only (immutable)var
— Mutable (can be reassigned)var score: Int = 100
val
by default, and only use var
when you know the value needs to change.