I am trying to call a method from another class but I get an exception error.
I have two classes and class 1 is the main class
Class 1 has an onclick<
If I've understood your question correctly, if you want to call the methods in a extended class, you need to make sure those methods are either public or protected.
Also omit the classname, eg just call method()
not class.method()
Just to elaborate on this some more, here is some code I just cooked up:
class class1 {
private void privateMethod() {
// do nothing
}
protected void protectedMethod() {
// do nothing
}
public void publicMethod() {
// do nothing
}
}
class class2 extends class1 {
private void testMethod() {
privateMethod(); // error - not visible
protectedMethod(); // works
publicMethod(); // also works
}
}