我有以下(第三方)类结构。我们称第三方项目为
现在我想写以下内容(这不是有效的Java代码):
ProjectSeriously
,请注意我使用System.out.println
代替其他复杂功能(100多行代码)。class A {
public void hi() {
// Do an important thing
System.out.println("Important thing A");
}
}
class B extends A {
public void hi() {
// Do some terrible, terrible things
System.out.println("TERRIBLE THING B");
// Do that important thing
super.hi();
}
}
现在我想写以下内容(这不是有效的Java代码):
class C extends B {
public void hi() {
// Do some not-so-terrible things
System.out.println("Ok thing C");
// Do that important thing
super.super.hi();
}
}
我需要将一个instanceof
B传递给这个神奇项目的其他部分,即ProjectSeriously
。由于这些方法是公共的,所以我觉得应该是可行的。