February 2019
Intermediate to advanced
442 pages
11h 46m
English
As we have seen, Kotlin is fully interoperable with Java so that you can write Java and Kotlin functions altogether in the same project and call them from each other. Let's understand how that magic happens. Before that, let's look at how things happen behind the scenes.
For example, you wrote a Kotlin function in the CheckOperability.kt file as follows:
fun greeting(name: String){ print(" Hello $name !!!")}
This code will be compiled by the Kotlin compiler and converted into byte code. The generated Java class file will be as follows:
public final class CheckInterOperabilityKt{ public static final void greeting(@NotNull String name) { //Some code for null type check added by Kotlin at this place. String str = " Hello " ...