• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

local inner classes

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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().
 
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks very much. I got it.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic