C++ 造的坑 Java 来补,补坑的路上 Java 接口怎么写?

public interface JInterface {public abstract void mthod1();}public class JClass implements JInterface {@Overridepublic void mthod1() {}}
public interface J8Interface1 { public default void methodDefault() { System.out.println("This is J8Interface1 default method!"); } void mthod1();}public interface J8Interface2 { public default void methodDefault() { System.out.println("This is J8Interface2 default method!"); } void mthod1();}public class JClass implements J8Interface1,J8Interface2 {@Overridepublic void mthod1() { System.out.println("Override in the Subclass");}@Overridepublic void methodDefault() {// J8Interface1的调用J8Interface1.super.methodDefault();// J8Interface2的调用J8Interface2.super.methodDefault();}public static void main(String[] args) {// TODO Auto-generated method stubJ8Interface1 j81= new JClass();j81.mthod1();j81.methodDefault();J8Interface2 j82= new JClass();j82.mthod1();}}
Override in the Subclass
This is J8Interface1 default method!
This is J8Interface2 default method!
Override in the Subclass
public interface J9Interface {
public default void methodDefault() {
System.out.println("This is J8Interface2 default method!");
this.methodPrivate();
methodStatic();
}
void mthod1();
public static void methodStatic() {
System.out.println("This is J9Interface9 static method!");
}
private void methodPrivate() {
System.out.println("This is J9Interface9 private method!");
}
}
关注公众号:拾黑(shiheibook)了解更多
[广告]赞助链接:
四季很好,只要有你,文娱排行榜:https://www.yaopaiming.com/
让资讯触达的更精准有趣:https://www.0xu.cn/

随时掌握互联网精彩
赞助链接
排名
热点
搜索指数
- 1 习近平的“川海”之喻 7904887
- 2 女子拒绝1人干3人的活被辞 法院判了 7809583
- 3 收入200万 清北高才涌入香港保险业 7713757
- 4 今天这几组数据 提气! 7616886
- 5 3岁男孩做扁桃体切除手术致脑死亡 7523138
- 6 清华学霸夫妻携手从军 7424262
- 7 尹锡悦囚室无空调 第一天菜单曝光 7329303
- 8 演员吴越逛菜市场被偶遇 7236983
- 9 高考院校哈工大热度首登全国榜首 7141804
- 10 乌克兰一官员在基辅遭近距离枪杀 7039553