August 2017
Intermediate to advanced
440 pages
10h
English
In Kotlin, we have two types of variables: var and val. The first one, var, is a mutable reference (read-write) that can be updated after initialization. The var keyword is used to define a variable in Kotlin. It is equivalent to a normal (non-final) Java variable. If our variable needs to change at some point, we should declare it using the var keyword. Let's look at an example of a variable declaration:
fun main(args: Array<String>) {
var fruit: String = "orange" //1
fruit = "banana" //2
}
The second type of variable is a read-only reference. This type of variable cannot be ...
Read now
Unlock full access