Variables in Kotlin

Variables in Kotlin are of 2 types –

var can be reassigned. For example – var age 4; age 5

We created a variable age with the value of and then we assigned the value to 5, so var can be reassigned.

But val can’t be reassigned. For example – val age 5; age 

We created a variable age with the value of 6 but when we try to reassign it to 6, Android Studio throws the error “Change ‘val’ to ‘var’”.