Home > Articles

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Summary

In mixed-language projects and during migration, you may use Kotlin and Java simultaneously in a project. Fortunately, most language concepts map naturally between the languages. For the remainder, it is important to understand how Kotlin compiles to Java bytecode and how you can write code that aids interoperability. On the Java side, this mainly includes adding nullability information and enabling shorter syntax in Kotlin, for example, by moving lambda parameters to the end. On the Kotlin side, it primarily encompasses using JVM annotations to adjust the compilation process, for instance, to generate static modifiers, descriptive names, or overloaded methods. This way, both languages can be used together without a large amount of overhead on either side.

  • + Share This
  • 🔖 Save To Your Account