我有一个Wicket页面类,它根据抽象方法的结果设置页面标题.
public abstract class BasicPage extends WebPage {
public BasicPage() {
add(new Label("title", getTitle()));
}
protected abstract String getTitle();
}
Run Code Online (Sandbox Code Playgroud)
NetBeans通过消息"构造函数中的可覆盖方法调用"警告我,但它应该有什么问题呢?我能想象的唯一选择是将其他抽象方法的结果传递给子类中的超级构造函数.但是很多参数很难读懂.
我有这个出现在测验中的代码
public class Main {
public static void main(String[] args) {
class b {
int i = 32;
b() { b(); }
void b() { System.out.println(++i); }
}
class d extends b {
int i = 8;
d() {}
void b() { System.out.println(--i); }
}
b b = new d();
}
}
Run Code Online (Sandbox Code Playgroud)
输出应该是什么?原来答案是-1,而我预计它是7。java 坏了吗?