51,411
社区成员
发帖
与我相关
我的任务
分享public class TestOverRide {
static class Father {
public int age;
void info() {
age = 100;
System.out.println(age);
}
}
static class Son extends Father {
public int age;
void info() {
super.info();
age = 10;
System.out
.println("son: " + age + " " + this.age + " " + super.age);
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Father father = new Father();
Son son = new Son();
father.info();
son.info();
}
}