• 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

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.
 
Get out of my mind! Look! A tiny ad!
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic