The Java static method can be invoked in Kotlin.
•
Java
Suppose we have a Java static method:
//Java code
public static void printFoo() {
System.out.println("foo");
}
Can you call this method in Kotlin?
Solution
Yes, you can
public class MyJavaClass {
public static void printFoo() {
System.out.println("foo");
}
}
Kotlin Code:
fun main(args: Array<String>) {
MyJavaClass.printFoo()
}
So easy =)
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
