我在oracle网站上学习过Java.在那,我看到了这样的例子
public class Horse {
public String identifyMyself() {
return "I am a horse.";
}
}
public interface Flyer {
default public String identifyMyself() {
return "I am able to fly.";
}
}
public interface Mythical {
default public String identifyMyself() {
return "I am a mythical creature.";
}
}
public class Pegasus extends Horse implements Flyer, Mythical {
public static void main(String... args) {
Pegasus myApp = new Pegasus();
System.out.println(myApp.identifyMyself());
}
}
Run Code Online (Sandbox Code Playgroud)
我能写这样的界面吗?我希望我只能在界面中编写抽象函数.那么为什么在oracle网站上他们给出了这样的例子呢?