1// Kotlin difference between val and var
2
3// val stands for read-only variable, and cannot be changed. (immutable variable)
4fun main() {
5 val number = 1
6 number = 2 // Not possible.
7}
8
9// var stands for variable, and can be changed. (mutable variable)
10fun main() {
11 var number = 1
12 number = number + 9
13 println(number) // this would return 10, because number got changed
14}
1// Kotlin difference between val and var
2
3// val stands for value, and cannot be changed. (immutable variable)
4fun main() {
5 var number = 1
6}
7
8// var stands for variable, and can be changed. (mutable variable)
9fun main() {
10 var number = 1
11 number = number + 9
12 println(number) // this would return 10, because number got changed
13}
14