Is it possible to compile an app using Java and Kotlin together?

5

Can I be part of the code in Java and elsewhere with Kotlin? Can anyone tell me?

    
asked by anonymous 22.03.2018 / 23:03

1 answer

7

Yes, you can. It is a feature spurred by Google that the new language of Android be interoperable with Java; you can create a class in Java and another in Kotlin, each one will be compiled into a .class file, and one can call the other in the code (Kotlin call Java or Java call Kotlin).

You can even adopt Kotlin gradually in your Java code, that is, exchange a Java class with the same class written in Kotlin, and so on.

Examples:

22.03.2018 / 23:14