抽象类
为什么要有抽象类?
因为父类方法有不确定性,我们在Animal中定义了一个方法,但是它会被子类的方法覆盖掉,我们就不知道这个方法原本是做什么的
1 public class test1 2 { 3 public static void main(String[] args) { 4 } 5 } 6 7 class Animal 8 { 9 String name; 10 int age; 11 12 //动物会叫 13 public void cry() 14 { 15 System.out.println("不知道怎么叫"); 16 //问题是这个方法永远都不会用到 17 } 18 }