无法使用 super 调用父接口的默认方法

时间:2021-08-01 09:22:47

标签: java java-8 default-method

interface WithDefinitionsInter {
    default void definedMeth() {
        System.out.println("inside interface");
    }
}
class WithDefinitionsImpl implements WithDefinitionsInter {
    public void definedMeth() {
        super.definedMeth(); // compilation error here
        System.out.println("inside class");
    }
}
public class QuizDef {
    public static void main(String par[]) {
        WithDefinitionsInter withDef = new WithDefinitionsImpl();
        withDef.definedMeth();
    }
}

谁能解释一下为什么我不能使用 super 关键字调用父接口的默认方法。

0 个答案:

没有答案