Calling Java from Kotlin
We'll cover the following
Calling code written in Java from within Kotlin .kt
files and .kts
scripts is straightforward for most part. Kotlin naturally integrates with Java, and we can use properties and methods without thinking twice—it almost always just works.
The Java code
To see this in action, and learn ways to work around occasional glitches you may run into, let’s write a Java class that we will then use from Kotlin.
Get hands-on with 1200+ tech skills courses.