day09-接口的默认方法的定义和使用

This commit is contained in:
2026-01-23 14:04:44 +08:00
parent 0b1e49133d
commit 7fa0295503
7 changed files with 59 additions and 3 deletions

View File

@@ -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");
}
}