var
vs. val
- Difference
Source: https://www.kotlintutorialblog.com/kotlin-var-vs-val/
var
: Mutable. Used to declare a mutable variable. It means the value of variable can be changed multiple times.val
: Immutable Used to declare a read only variable. It means once the value is assigned to variable, that can’t be changed later.
val
is same as final
in Java.