My code looks like this:
class A {
void myMethod() {
...
}
class B implements class C {
// ... how can I call myMethod here?
}
}
I am sorry if I'm not explicit enough or if there is any error in my question.
My code looks like this:
class A {
void myMethod() {
...
}
class B implements class C {
// ... how can I call myMethod here?
}
}
I am sorry if I'm not explicit enough or if there is any error in my question.
You should be able to call the method directly:
class A {
void myMethod() {
...
}
class B implements class C {
public void init() {
myMethod(); // calls myMethod() from A
}
}
}
In that case that class B also has a method named "myMethod", then see this question: Calling outer class function from inner class
class A {
void myMethod() {
...
}
class B implements class C {
public void init() {
// calls myMethod from A even tho myMethod is also defined on B
A.this.myMethod();
}
void myMethod() {
}
}
}
I can only guess that this answers your question, but it's hard to tell since you didn't provide the actual code that you had the problem with.
Use this to run a method in a different class:
class.method();
This will run method method in class class.
If the method you wanted to call was in the same class you were calling it from you could just write the method name:
method();