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 local inner classes 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 "local inner classes" Watch "local inner classes" New topic

local inner classes

geethal rodrigo

Joined: Jul 18, 2007
Posts: 3
when locan inner class object is created that object can only access within the method because of the variable scope.IS THERE ANY WAY TO ACCESS THE LOCAL INNER CLASS FROM THE MAIN METHOD BY ONLY USING INNER CLASS REFERENCE .I TRYIED EVERYTHING .PLEASE HELP.

class Outer{
void m(){
class Inner{
void m2(){
System.out.println("It works");
Inner i1=new Inner();

class Main extends Outer{
public static void main(String arg[]){
Outer a2=new Outer();
Like this I want to access m2().
Manfred Klug
Ranch Hand

Joined: Jun 04, 2007
Posts: 377
Hi geethal,

the only way to use an instance of a local inner class outside of the method, is something like this:
geethal rodrigo

Joined: Jul 18, 2007
Posts: 3
Thanks very much. I got it.
I agree. Here's the link:
subject: local inner classes
It's not a secret anymore!