This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Java in General and the fly likes Inner Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Inner Class" Watch "Inner Class" New topic
Author

Inner Class

Nelson Nadal
Ranch Hand

Joined: Jun 06, 2002
Posts: 169
Just thinking... is there a way that I can call the class A (the one outside the TestClass) in main method? The codes here is only in a single file. Thanks.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Not without using reflection and a factory class, but then that begs the question, why not either rename the outer class A or better put it in a separate package and file. The inner class A hides the outer class just like a method local variable with the same name as an instance variable will hide it.
Here's a reflection solution:


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Nelson Nadal
Ranch Hand

Joined: Jun 06, 2002
Posts: 169
Thanks sir Morris... I appreciate
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inner Class