this和super的例题,结果显示不了!
这个程序是书上的,可是运行结果和书上的不一样。print方法里的语句好象没用,只显示了DEmoSuper。帮我看看!谢谢!class Person
{
public int c;
private int age;
private String name;
protected void setName(String name)
{
this.name=name;
}
protected void setAge(int age)
{
this.age=age;
}
protected void print()
{
System.out.println("Name="+this.name+" Age="+this.age);
}
}
public class DemoSuper extends Person
{
public void print()
{
System.out.println("DemoSuper:");
}
public static void main(String[] args)
{
DemoSuper ds=new DemoSuper();
ds.setName("kevin");
ds.setAge(22);
ds.print();
}
}