Wrapping Up
It’s highly likely that you’ll have a need to intermix Kotlin and Java code on your projects. In this chapter we’ve seen how easy it is to use Java from Kotlin, but the other way around requires some effort and planning.
You may use any Java library from your Kotlin applications and also use Kotlin libraries from within Java applications. You may also use both Java and Kotlin source files side by side in your projects. The Kotlin compiler has facilities to enable joint compilation of source files written in Java and Kotlin.
Calling into Java code from Kotlin is fairly straightforward and mostly works without any effort. You may use a pair of backticks to escape any keyword conflicts that may arise. Calling from Java to Kotlin requires ...
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