To use the Numbers class defined in the Java code from your Kotlin code, you can create an instance of the Numbers class in your Kotlin code using the new keyword, and then call its myfunction method. Here's an example:
Java code (Numbers.java):
public class Numbers { public void myfunction(){ System.out.println("I am from java file. My class name is Numbers. I'm getting called by kotlin code\n"); } }
Kotlin code (Main.kt):
fun main() { val myJavaObject = Numbers() myJavaObject.myfunction() }
In this code, we create an instance of the Numbers class using the new keyword and store it in the myJavaObject variable. We can then call the myfunction method on this object to print out the message defined in the Java code.
Make sure that the Java code is in the same directory as your Kotlin code and that the Java code is compiled before you run your Kotlin code.