Summary
Interoperability between Java and Kotlin is very strong by default. However, there are a number of options available to us so that we can improve how we can use Kotlin from Java. We can use the @JvmName annotation to control the name Java classes that are generated from our Kotlin code. By using the @JvmOverloads annotation, we can generate method overloads to help us take advantage of default parameter values that are not supported in Java. While Kotlin does not have a static keyword, we can use the @JvmStatic annotation to mark properties and methods of companion objects. By doing this, the compiler will generate true JVM static methods for accessing these properties and methods with a syntax that feels much more natural from Java. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access