June 2018
Intermediate to advanced
310 pages
6h 32m
English
In Java, variables can be declared final. Final variables can be assigned only once:
final String s = "Hi";s = "Bye"; // Doesn't work
Kotlin urges you to use immutable data as much as possible. Final variables in Kotlin are simply val:
val s = "Hi"s = "Bye" // Doesn't work
If you do have a case in which you would like to reassign a variable, use var instead:
var s = "Hi"s = "Bye" // Works now
Read now
Unlock full access