核心代码
interface Animal {
void run();
void eat();
default void breath(){
System.out.println("使用氧气呼吸");
}
static void look(){
System.out.println("animal 正在观察");
}
}
public class TestInterface implements Animal {
@Override
public void run() {
System.out.println("run");
}
@Override
public void eat() {
System.out.println("eat");
}
public void cry(){
System.out.println(" cry ");
}
}
class Test {
public static void main(String[] args) {
TestInterface testInterface = new TestInterface();
testInterface.run();
testInterface.eat();
testInterface.cry();
testInterface.breath();
Animal.look();
}
}