This code will cause a runtime error of "NullPointerException".
The problem is that the instance of the enclosing class
Test is not
yet set in the inner class when the call to the print() method was made.
When a call is made to the constructor of an inner class
(InnerMemberSubclass), the instance of the enclosing class
(Test) is passed on to it. This instance will be stored by the inner class as the variable this$0 to access the outerclass' members .
However, in this case, before this was all done, a call to the superclass' constructor was made (InnerMemberSuperclass) . The superclass calls print(), and since it is overridden, the InnerMemberSublcass' print() method is the one invoked. But at this point, this$0 has not yet been set, so that method cannot locate the member variable
s thus causing the error.
[ August 20, 2003: Message edited by: Alton Hernandez ]