Interoperability

In this chapter, we will focus on the interoperability of Java and Kotlin. Interoperability refers to the ability to use both the Java and Kotlin languages in a single project. We can call Kotlin functions in Java as well as Java methods and variables in Kotlin code. This gives us the advantage of code reusability. For example, if we have an existing Java project with classes and functions, then we do not need to rewrite everything in Kotlin from scratch. Instead, we can use each and every line of Java code in Kotlin and start writing new functionalities here. Similarly, we can call Kotlin code in Java.

The following topics will be covered in this chapter:

  • Calling the Java static variable in Kotlin
  • Calling the Java static function in Kotlin
  • Calling the Java collection in Kotlin
  • Calling the Java class in Kotlin
  • Handling Kotlin reserve keywords
  • Calling the Kotlin class in Java
  • Calling the Kotlin function in Java
  • Calling the Kotlin extension function in Java
  • Using JVM annotations in Kotlin
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.163.62