I am not very sure how to title this question properly, I will just try to describe it as clear as I can blow.
Interface InterfaceB {
void methodB();
}
Class ClassB implements InterfaceB {
void methodB() {
//...
}
}
Class ClassA {
InterfaceB methodA() {
return new ClassB();
}
}
Class MyClass {
public static void main(String[] args) {
ClassA a = new ClassA();
InterfaceB b = a.methodA();
b.methodB(); // override this guy
}
}
I want to override methodB, without change ClassA and ClassB. Appreciate any ideas.
Aucun commentaire:
Enregistrer un commentaire