Variables in Kotlin

Defining variables in Kotlin can be done in several ways, such as the following:

// Immutable
val separatorChar: String = ",";

// Mutable
var noOfTimesMethodsInvoked = 0;

The val keyword can be used to define Immutable variables, and the var keyword can be used to define Mutable variables. The type of the variable can be specified, but when it isn't, it will be inferred based on what value is being set. In the case of the noOfTimesMethodsInvoked variable, the type will be inferred as Int by default.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.71.220