【发布时间】:2016-02-08 13:30:38
【问题描述】:
class Base {
int value = 0;
Base() {
add();
}
void add() {
value += 10;
}
int get() {
return value;
}
}
class Derived extends Base {
Derived() {
add();
}
void add() {
value += 20;
}
}
调用派生类构造函数,然后add(),值变成40,为什么?
【问题讨论】:
标签: java inheritance