Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes method-local inner class problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "method-local inner class problem" Watch "method-local inner class problem" New topic
Author

method-local inner class problem

Juwonlo Ibigbami
Ranch Hand

Joined: Nov 03, 2006
Posts: 83
please, given a method-local-inner-class, what will happen to the class if the method is called from with the class
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
Howdy!

This example cause a stack overflow. Can you see why?




Yours,
Bu.


all events occur in real time
dolly shah
Ranch Hand

Joined: Jun 18, 2007
Posts: 383


Refer above code. Your doubt will be clear.

You can call enclosing method from within that method's inner class, it is legal, your code will compile. But as you know we cannot access local variables of enclosing method from method-local inner class then why you need to invoke that method from the class.

When I ran this program I got output like this.
"enclosing method".
-Looks like code doesn't go into the method-local inner class. That's why it doesn't print "inner class method".

Anybody have any idea?


SCJP-1.5<br />SCWCD-1.4
ranjitsingh thakurratan
Greenhorn

Joined: Jul 25, 2007
Posts: 18


Dolly, there wasn't any inner class instance created and a method called..hence the inner class never got executed.

from with in the method local inner class call Inner x = new Inner();

RJ
Juwonlo Ibigbami
Ranch Hand

Joined: Nov 03, 2006
Posts: 83
Thanks to you all, what of if the method was called insede the outer class?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: method-local inner class problem