Override
1、两个类具有继承关系
2、两个方法的名称相同、入参想同(包括个数、参数的类型)、返回值相同
public class OverrideTest {
public static void main(String[] args) {
Cat cat = new Cat();
cat.eat();
}
}
class Animal{
public Animal() {
}
public void eat(){
System.out.println("Animal like eat");
}
}
class Cat extends Animal{
public Cat() {
}
@Override
public void eat() {
System.out.println("cat like eat fish");
}
}
标签:eat,重写,void,Cat,class,Animal,方法,public
From: https://www.cnblogs.com/xindinglei/p/16743394.html