Calling Java code from Kotlin works seamlessly in nearly all cases. Still, there are some practices you can follow to avoid special cases of conflict and aid interoperability even further.
- Add appropriate nullability annotations to all nonprimitive return types, parameters, and fields to avoid ambiguous platform types.
- Use the accessor prefixes get, set, and is so that they are automatically accessible as properties from Kotlin.
- Move lambda parameters to the end of signatures to allow for the simplified syntax where you can pull the lambda out of the parentheses.
- Do not define methods that can be used as operators from Kotlin unless they indeed make sense for the corresponding operator.
- Do not use identifiers in Java that are hard keywords in Kotlin to avoid escaping.
Learn more about Kotlin with Kotlin for Android Development.