October 2019
Intermediate to advanced
434 pages
11h 54m
English
One of the biggest differences between Kotlin and Java is the handling of null types. Because of this, it is one part of the interop story that must be given careful thought. Thankfully, our tools can help make this easier.
To explore the handling of null across language boundaries, we'll, once again, return to the Person class. In our Person example, both properties are defined as non-null String types:
open class Person(val firstName: String, val lastName: String)
Because the Kotlin compiler knows these values will not be null, we can safely reference them without any type of null check, as shown in the following snippet:
person.firstName.length
However, when we access those properties from Java, we must store them as nullable ...
Read now
Unlock full access