File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Method Local inner class" Watch "Method Local inner class" New topic

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.



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

Joined: Aug 03, 2008
Posts: 9465

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
I agree. Here's the link:
subject: Method Local inner class
It's not a secret anymore!