1.认识多态
class animals{String name="animals";public void run(){}
}
class cat extends animals{String name="cat";@Overridepublic void run(){System.out.println("cat run");}
}
class dog extends animals{String name="dog";@Overridepublic void run(){System.out.println("dog run");}
}
class demo{public static void main(String[] args) {//这就是多态animals a = new cat();a.run();animals b = new dog();b.run();System.out.println(a.name);System.out.println(b.name);//成员变量不具有多态性}
}