2022年5月24日

摘要: Animal a1 = new Cat() 多态的前提和体现: 有继承/实现关系 有方法重写 有父类指向子类对象 多态中成员的访问特点: 成员变量: 编译看左边,运行看左边 成员方法 :编译看左边,执行看右边 多态的优点和缺点: 缺点:不能访问子类特有功能 优点:提高了程序的扩展性 阅读全文

posted @ 2022-05-24 22:51 LutixiaGit 阅读(24) 评论(0) 推荐(0)

摘要: 动物类的设计 package Animals; public class Animal { private String name; private String age; public Animal() { System.out.println("动物"); } public Animal(Str 阅读全文

posted @ 2022-05-24 21:25 LutixiaGit 阅读(62) 评论(0) 推荐(0)