package com.shujia.day09;
import java.nio.channels.Pipe;
/*
多态的好处
1、提高了程序的维护性(由继承保证)
2、提高了程序的扩展性(由多态保证)
*/
class Animal{
String name;
int age;
public Animal() {
}
public Animal(String name, int age) {
this.name = name;
this.age = age;
}
public void eat(){
System.out.println("吃");
}
public void sleep(){
System.out.println("睡");
}
}
class Dog extends Animal{
@Override
public void eat() {
System.out.println("
标签:System,day09,可扩展性,void,多态,eat,sleep,println,public
From: https://www.cnblogs.com/qiwei-bigdata/p/18344017