xxxxxxxxxx
val and var both are used to declare a variable. var is like general variable and it's known as a mutable variable in kotlin and can be assigned multiple times. val is like Final variable and it's known as immutable in kotlin and can be initialized only single time.
xxxxxxxxxx
val firstName: String = "Chike"
val variable name: Typeofthevariable = TheValueofyourvariable
xxxxxxxxxx
+----------------+-----------------------------+---------------------------+
| | val | var |
+----------------+-----------------------------+---------------------------+
| Reference type | Immutable (once initialized | Mutable (can change value)|
| | can't be reassigned) | |
+----------------+-----------------------------+---------------------------+
| Example | val n = 20 | var n = 20 |
| | n++ | |
+----------------+-----------------------------+---------------------------+
xxxxxxxxxx
val name = ”Marcin” // Can't be changed
var age = 5 // Can be changed
age++