This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma 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

JavaRanch » Java Forums » Java » Java in General
Bookmark "Inner Class" Watch "Inner Class" New topic

Inner Class

Nelson Nadal
Ranch Hand

Joined: Jun 06, 2002
Posts: 170
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: 170
Thanks sir Morris... I appreciate
I agree. Here's the link:
subject: Inner Class
It's not a secret anymore!