标题: 超人多态 [打印本页] 作者: 路好营 时间: 2015-11-6 23:48 标题: 超人多态 class Demo_SuperMan {
public static void main(String[] args)
{
Person s = new SuperMan();
s.tsy();
System.out.println(s.name);
SuperMan m = (SuperMan)s;
m.fly();
}
}
class Person {
String name = "john";
public void tsy(){
System.out.println("谈生意");
}
}
class SuperMan extends Person {
String name = "SuperMan";
public void tsy(){
System.out.println("谈几个亿的生意");
}