Java 什么是Interface.super

Java 什么是Interface.super,java,Java,我最近在java中使用了默认方法。 在它的实现中,我发现 public interface DefaultMethod { default String showMyName(String name){ return "Hai "+name; } } public class DefaultMethodMainImpl implements DefaultMethod{ @Override public String showMyName(

我最近在java中使用了默认方法。 在它的实现中,我发现

public interface DefaultMethod {
    default String showMyName(String name){
        return "Hai "+name;

    }
}


public class DefaultMethodMainImpl implements DefaultMethod{

    @Override
    public String showMyName(String name){
        return DefaultMethod.super.showMyName(name);

    }
}

我的问题是在DefaultMethod中。super在哪里super将调用它?除了Object之外没有超类吗超级将返回什么?

如果在
类中使用
super
,它通常指该类的祖先(扩展
ed类或
对象

在覆盖
接口
默认
方法的情况下,必须指定要调用的默认实现的特定接口,因此

<Interface>.super.<method>();
.super.();

另请参见。

()会考虑<代码> <代码>为静态,而事实并非如此。因此,使用关键字
super
,它是一个引用变量,用于引用“父”对象。

super是一个关键字,而不是超级/父类的引用或对象,它将调用超级/父类的方法或构造函数。接口可以
扩展
其他接口。谢谢你说得对,但我的疑问是这里DefaultMethod接口没有超类,那么调用哪个构造函数?你不能使用超类,那么在该接口/类中不使用super关键字谢谢你的答案是正确的。