Originally Posted by copeg
Thank you copeg,
By removing the final
from the line "private final int num = 10;", the program tends to have "making forward references" problem.
Child constructor -> Parent constructor -> initialization of parent's non-final variables, then goes into Parent's constructor body. I can understand these by reading the documents you mentioned.
The part "Calling subclassed methods from constructors" also explains a little bit of the case that I am having.
But, what about the code flow "walking"?
"final" variables initialization goes prior to the constructor, I couldn't find it from the "Object initialization in Java" link above.
Assume this case is true: the line "private final int num = 10;" is going to be executed TWICE ?
I am traveling with the code line by line under debug mode, and when the line "private int x = 4;" is held, Parent.value is already assigned to be 10. Afterward, the debugger will just step into the next line "private final int num = 10;" and step out with no error; final "int type" variable being assigned a value twice?
? x 1000, Please Help......