我只是试着设置一个变量,告诉我超级构造函数已经完成而没有浪费我的代码.所以我记得如何初始化类变量; 在超级构造函数之后但在类构造函数之前.但是如果你看一下这个例子,有一些奇怪的事情:
public class Init {
public Init() {
System.out.println("Init instance of " + this.getClass().getSimpleName());
System.out.println("syso Init:");
this.syso(false);
}
protected void syso(boolean childCall) {
System.out.println("should not be printed because the method is overwitten");
}
public static class Child extends Init {
private final boolean finalTrueA = true;
private final boolean finalTrueB;
private final boolean finalTrueC;
private boolean nonFinalTrueA = true;
private boolean nonFinalTrueB;
private boolean nonFinalTrueC;
{
this.finalTrueB = true;
this.nonFinalTrueB = true;
}
public Child() {
super();
this.finalTrueC = …Run Code Online (Sandbox Code Playgroud)