wood burning stoves 2.0*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "local inner classes" Watch "local inner classes" New topic
Author

local inner classes

geethal rodrigo
Greenhorn

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();
i1.m2();

}
}
class Main extends Outer{
public static void main(String arg[]){
Outer a2=new Outer();
a2.m();
xxxxxxx.m2();
}
}
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
Greenhorn

Joined: Jul 18, 2007
Posts: 3
Thanks very much. I got it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: local inner classes