Welcome to the JavaRanch Maha! The enclosing class could invoke the method in which the class is declared and created. If the method returns a reference to a new instance of the method local class, then the enclosing class can invoke a method on the new instance using the returned reference. I'm sure that really isn't the answer that you are looking for. The correct answer is "no". The enclosing class has no way to invoke a method on a method local class unless a reference to the new instance of the method local class is made available to the enclosing class. I hope I haven't made that even more confusing than it was previously.
Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Thanks for your prompt reply Dan. Actually K& B suggested (as you did) that using the reference variable we can access the method-inner class methods. But when I tried to code the same, compiler scolded me. That made me to post the question in this forum. However, I too think that the method-inner class methods are inaccessable. Any other comments ?. Thanks again. Maha
Just have a look at the following Code. Here the reference of the class is returned to the Outer class. Using this reference you can call any method of the 'method local inner class'.
This is one of the reason for not allowing the 'method local inner class' to have access to local variables of the method. Hope this helps! Regards, Hari [ November 29, 2003: Message edited by: Hari G ]
Originally posted by maha prataps: Thanks hari for such a wonderful explanation.
hello, I steped in, coz i have got some querry::: why do we need access modifiers for the method-local inner classes. I have read somewhere that they can have final and abstract as their modifiers, obviously both cannot be applied together. Pls throw some light on this.