类A实现I需要方法的接口doAction()。如果我从 classA 的类中调用一个方法B,并将“ this”(class A)传递给该方法,我如何从 class 中的方法调用存在于类A中的方法B?例如:
class A implements I {
public void start() {
B.myMethod(this);
}
@Override
public void doAction() {
// Do stuff...
}
}
Class B {
public void myMehtod(Class theClass) { //How would I accept 'this', and...
theClass.doAction(); //How would I call the method?
}
}
我这样做是为了自定义库,而不知道扩展类的确切名称I。