day09-接口的默认方法的定义和使用
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package com.inmind.interface_default02;
|
||||
|
||||
public class MyInterfaceImpl2 implements MyInterface{
|
||||
@Override
|
||||
public void method() {
|
||||
System.out.println("实现类MyInterfaceImpl2的method方法");
|
||||
}
|
||||
|
||||
//ctrl+o
|
||||
@Override
|
||||
public void method1() {
|
||||
//MyInterface.super.method1();//重写的作用:沿用父类的功能
|
||||
System.out.println("实现类2重写了接口中的默认方法method1");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user