Kotlin miniguide #6 Functions interoperability with Java

It’s possible to call kotlin functions from within Java.

The following Kotlin code:


//file name Util.kt

@file:JvmName("Utils")

package test

fun displayName() {... }

Is compiled to:


package test

class Utils() {

public static void displayName( ){...}

}

And it can be called this way from Java:


test.Utils.displayName();

More details here

Lascia un commento