Where should I use var and where val?

Technology CommunityCategory: KotlinWhere should I use var and where val?
VietMX Staff asked 4 years ago

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"