wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes How to access a shadowed class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "How to access a shadowed class?" Watch "How to access a shadowed class?" New topic
Author

How to access a shadowed class?

Richard Hayward
Ranch Hand

Joined: Feb 15, 2012
Posts: 68
    
    1
Inside ClassChoiceTest, the class AClass is shadowed by a nested class definition of the same name.



Is there any way to refer to the non-nested AClass from inside ClassChoiceTest?
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3253
    
    2
Yes, it is possible but there is a catch. You have to define the classes in a non-default package and then you can access the non-nested class using the packagename.Aclass. You can't do this with default package because it is not possible to "import" the default package.

HTH,
Paul.


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
Richard Hayward
Ranch Hand

Joined: Feb 15, 2012
Posts: 68
    
    1
Thank you Paul.

Regards
Richard
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to access a shadowed class?
 
Similar Threads
Can a class be defined inside an interface?
newInstance() doubt
Abstract class??
how to get the answer as 15 for this code
Null Pointer Exception ???