`class Demo(data:String)` `data` will only be acc...
# android
l
class Demo(data:String)
data
will only be accessible in the constructor of this class
class Demo(val data:String)
you are also creating a
data
field with its getter and it will be accessible for the entire class it can also be :
class Demo(var data:String)
if you want getter and setter or
class Demo (private val data: String)
if the field shouldn’t be public A better way to understand that is, create both classes in your Android Studio go to the menu
Tools> Kotlin > Show Kotlin Bytecode
and the click on the button
Decompile
to see the generated java source code… it will make more sense