Combine Java with Kotlin in Android

Viewed 25441

I am slightly moving from Java to Kotlin in android app development, but there are some cases where I don't want to code in Kotlin and want those particular cases be written in Java:

  • It is effort-saving that Kotlin removes extra usage of findViewByIds
  • I know that it is now null-safety which oppositely Java always triggered with NullPointerException
  • Lambda expressions are also provided and many other features.

But still, some of my codes cannot be written in Kotlin such as static members or non-primitive fields.

Kotlin annotations actually can replace those static members. But love some coding features of Java and dont want to leave that.

My question is can I combine Java and Kotlin together?

4 Answers
Related