每日日报2020 9/10

今天将前几天学习的东西整合了一下,从菜鸟教程学习了一段代码,大致如下:

class Animal

{

void eat()

{

System.out.println("animal : eat");

}

}

class Dog extends Animal

{

void eat()

{

System.out.println("dog : eat");

}

void eatTest()

{

this.eat();

// this 调用自己的方法

super.eat();

// super调用父类方法

}

}

public class Test

{

public static void main(String[] args)

{

Animal a = new Animal();

a.eat();

Dog d = new Dog();

d.eatTest();

}

}

posted @ 2020-09-10 11:22  宋振兴  阅读(43)  评论(0编辑  收藏  举报