How to Declare Variable in Kotlin1 min read

In Kotlin either var or val keyword is used to declare the variable.

We don’t want to specify the type of variable, Kotlin implicitly conveting to the proper data types.

val in Kotlin : The variable declared using val keyword cannot be changed once the value is assigned.

It is similar to final variable in Java.

var in Kotlin – The variable declared using var keyword can be changed later in the program. It corresponds to regular Java variable.

Go through the above program to get more understanding about Kotlin var and val.

Kotlin Code:


Leave a Comment