Initialization Sequence of this code:
- When outer is created in line 1 the constructor OuterTest(
String id) is called
and „id“ of OuterTest is initialized to „STP“ and „Default Constructor
is printed to console.
- Then the instance „inner“ of the inner class is created. As inner class extends
The outer class the Default-Constructor of OuterTest is called and „NonDefault
Constructor“ is printed.
MY QUESTION is: Why didn’t get „id“ of OuterTest the value „Default“ which is
Set by the default constructor of „OuterTest“?
Instead the „Outer.Test.this.id“ keeps ist old value „STP“ from the creation of the
OuterTest-instance „outer“.
C:\Java\EigeneJavaProgramme>
java OuterTest
NonDefault-Constructor
Default-Constructor
InnerTest STP
InnerTest Default
=> Question: Why is „OuterTest.this.id“ still „STP“ and not „Default“?