+ 1

What is difference between var and Val.

9th Jul 2020, 9:06 AM
æshrîth.htm
æshrîth.htm - avatar
2 Respostas
+ 2
This is what I found for you from internet "var is like a general variable and can be assigned multiple times and is known as the mutable variable in Kotlin. Whereas val is a constant variable and can not be assigned multiple times and can be Initialized only single time and is known as the immutable variable in Kotlin." The original website https://medium.com/mindorks/kotlin-series-val-vs-var-difference-android-kotlin-ecad780daeb7
9th Jul 2020, 9:11 AM
Nilesh
Nilesh - avatar
+ 2
The word val stands for constant value let say you have 1 value val x:Int = 6 this 6 can not be changed(reassigned) Which means you will get error when you try to reassigned or chane the value x = 7//error But var stands for variable as its name it's name it can be changed every where I.e var n : Int = 10 Then n = 15//it can be changed every where
15th Jul 2020, 3:56 PM
Ananiya Jemberu
Ananiya Jemberu - avatar