posted 19 years ago
When I compile the above its OK
at point (***1) I instatiate an instanance of the Obj2 class inherited in Obj3
at point (***3) I do the same thing and I can “drop” the outter class instance since the this is passed implicitly to the method. I can also drop the qualifing Obj3.Obj2 since I’m in a method of Obj3 so I use just Obj2
Question:
At point 2 I do NOT understand why the line Obj2 oo2=new Obj1().new Obj2()
its ok !!! I think it should be Obj1.Obj2 oo2=new Obj1().new Obj2(); since the variable instantiated it’s the inner class of Obj1, and we are in a method of Obj3 ???
I notice that if Obj3 does not extend Obj1 I get a compile error for the above, but I do not understand how inheritance can make the line compile, after all we are dealing with an object that does not belong to this class: new Obj1().new Obj2();
Edited by Corey McGlone: Added CODE Tags and Reformatted Code for readability.
[ April 22, 2004: Message edited by: Corey McGlone ]
"Did anyone understand what I have just explained? ... because I did not!"