I am trying to learn Kotlin. What is val
, var
and internal
in Kotlin compared to Java?
In Java:
RadioGroup radio
val
: immutable data variable
var
: mutable data variable
When you converted your Java code to Kotlin:
A converter found that you have not initialised variables, so it made them var
(mutable) as you will initialise them later.
Probably your variables are unused, so the converter made them internal, guessing you will not use them outside of your package.
For more information on var
and var
read this, and for internal
read this.