August 2017
Intermediate to advanced
440 pages
10h
English
With Android projects, Kotlin is compiled to Java bytecode that runs on Dalvik Virtual Machine (before Android 5.0) or Android Runtime (Android 5.0 and newer). Both virtual machines can execute only the code that is defined inside a class. To solve this problem, the Kotlin compiler generates classes for top-level functions. The class name is constructed from the file name and the Kt suffix. Inside such a class, all functions and properties are static. For example, let's suppose that we define a function within the Printer.kt file:
// Printer.kt
fun printTwo() {
print(2)
}
Kotlin code is compiled into Java bytecode. The generated bytecode will be analogical to the code generated from the following Java ...
Read now
Unlock full access