October 2019
Intermediate to advanced
434 pages
11h 54m
English
The accessing of properties is an interesting example of the differences inherent in using a Kotlin class from either Kotlin or Java. To illustrate this, we'll once again define the following Person class:
open class Person(val firstName: String, val lastName: String)
As we discussed previously in Chapter 5, Modeling Real-World Data, Kotlin properties do not require explicit getters and setters as they will be generated automatically by the compiler. When accessing properties from Kotlin, it's a general convention to use property access syntax and reference the property names directly. But how does this work from Java?
When consuming a Kotlin class from Java, we cannot use property access syntax. However, we can make use of ...
Read now
Unlock full access