Type of Variable: Mutable or immutable

Type of Variable: Mutable or immutable

Immutable Variable, contents can only be assigned initially, can not be modified
1
val x: String="Jack"
2
val numbers: Int = 10
3
val pi: Float=3.14
Copied!
Mutable Variable:
1
var x: String="Dave"
2
x="John"
3
var num: Int=1
4
Num=2
5
var pi=3.14
6
pi=3.1416
Copied!
Last modified 1yr ago
Copy link