Sobes.tech
Intern

What is the difference between val and var in Kotlin?

sobes.tech AI

Answer from AI

val is used to declare an immutable (read-only) variable. After assigning a value to it, it cannot be assigned another.

var is used to declare a mutable variable. It can be assigned a new value at any moment.