well jean nice try first of all. I never thought about that syntax. But jean that will not work because the special syntax to access outer class instance is only available to the inner class. It is just a compiler optimization. You can read my blog if you want the complete details. The link is in my signature...
well I would say Yes, that's the solution. But why do you want to return the outer class instance
jean-gobert de coster
Joined: Dec 04, 2008
Originally posted by Ankit Garg: well I would say Yes, that's the solution. But why do you want to return the outer class instance
Well I don't have any particular scenario for this, so it's more out of curiosity.
The main reason being: when you instantiate an inner class, you also instantiate its outer class. So what happens to that instance.
Actually, a question comes to mind: how does this all work in terms of GC?
I mean, ok I create an instance of MyOuter and an instance of MyInner, so I have one instance of each on the heap. And on the stack I have my "inner" variable. What prevents the instance of MyOuter from being GC'ed?