January 2018
Intermediate to advanced
434 pages
14h 1m
English
Now, let's look at how to create global variables in Kotlin. There are two ways to do it. Let's look at them one by one:
fun main(args: Array<String>) { var student:Student?=null}
However, this approach will result in testing for nullability whenever you use it:
println(student?.age)
fun main(args: Array<String>) { lateinit var student:Student student=Student() ...
Read now
Unlock full access