0 votes
in Kotlin by
Where should I use var and where val?

1 Answer

0 votes
by

Use var where value is changing frequently. For example while getting location of android device:

var integerVariable : Int? = null

Use val where there is no change in value in whole class. For example you want set textview or button's text programmatically.

val stringVariables : String = "Button's Constant or final Text"

Related questions

0 votes
asked Oct 5, 2021 in Kotlin by rajeshsharma
0 votes
asked Oct 6, 2021 in Kotlin by Robin
...