|
@@ -3,16 +3,16 @@ package com.sf.day10.homework.homework1;
|
|
public class TestLiveAble {
|
|
public class TestLiveAble {
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
// 创建实现类(子类)对象
|
|
// 创建实现类(子类)对象
|
|
- Animal a = new Animal();
|
|
|
|
|
|
+ LiveAble liveAble = new Animal();
|
|
// 调用实现后的方法
|
|
// 调用实现后的方法
|
|
- a.eat();
|
|
|
|
- a.sleep();
|
|
|
|
- a.breathe();
|
|
|
|
|
|
+ liveAble.eat();
|
|
|
|
+ liveAble.sleep();
|
|
|
|
+ liveAble.breathe();
|
|
//创建实现类(子类)对象
|
|
//创建实现类(子类)对象
|
|
- Plant p = new Plant();
|
|
|
|
- p.eat();
|
|
|
|
- p.sleep();
|
|
|
|
- p.breathe();
|
|
|
|
|
|
+ LiveAble liveAble1 = new Plant();
|
|
|
|
+ liveAble1.eat();
|
|
|
|
+ liveAble1.sleep();
|
|
|
|
+ liveAble1.breathe();
|
|
//通过接口调用静态方法
|
|
//通过接口调用静态方法
|
|
LiveAble.drink();
|
|
LiveAble.drink();
|
|
}
|
|
}
|