File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Method Local inner class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Method Local inner class" Watch "Method Local inner class" New topic
Author

Method Local inner class

Himalay Majumdar
Ranch Hand

Joined: Sep 28, 2008
Posts: 324
In the code below, if I comment Lines 13, 16 I am able to print the final String "Show" in Line 11.
Is there any way I can access and print all the Strings inside the shows method.



OUTPUT

MyOuter
Inner
Inner


SCJP 1.6, SCWCD 5.0, SCBCD 5.0 [loading..]
Ruben Soto
Ranch Hand

Joined: Dec 16, 2008
Posts: 1032
I don't think you can do that because the x inside the method local inner class will shadow the local variable x inside the method.


All code in my posts, unless a source is explicitly mentioned, is my own.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Ruben is right. There is no way of doing that


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Himalay Majumdar
Ranch Hand

Joined: Sep 28, 2008
Posts: 324
Thats wat I thought..thanks guys
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Method Local inner class