How to call a top level kotlin function in java?

Viewed 1131

Assume a kotlin function is defined outside of a class as top level function.

Util.kt:

class Util {
   fun bar()
}
fun foo(){}

How can I call method foo() in Java?

1 Answers

foo will be compiled to a static function in a class whose name is that of the Kotlin source file with the suffix Kt - so in this case, you can say UtilKt.foo().

Related