I have 2 files. I call the method MyFunc in MyClass.java from main in MyTest.java. That's all I'm trying to do. I put them both in the same package, and it still won't run. I now get a run-time error saying "NoSuchMethod" when I run MyTest. Why??
Also, is there no way to call a method (via the import statement) without extending it's class, and putting both the caller class and the callee class in the same package?
Anyway, here's my 2 files:
Here's Mytest.java:
package com.util;
public class MyTest extends MyClass
{
public void main (
String[] args)
{
MyTest obj = new MyTest();
obj.MyFunc();
}
}
And here's my MyClass.java file:
package com.util;
public class MyClass
{
public void MyFunc()
{
Suystem.out.println("Printed from MyFunc");
}
}