aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes question about static inner 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 "question about static inner class?" Watch "question about static inner class?" New topic
Author

question about static inner class?

dragon ji
Ranch Hand

Joined: Oct 31, 2002
Posts: 110
is this statement right?
Instance members of a static inner class can be
referenced using the class name of the static inner class.
help me ,please.


scjp 1.4<br />challenge haven't limit!
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
By definition the term "static inner class" is contradictory. An "inner class" is a nested class that is not static.
A static nested class behaves like a top-level class. An instance of a static nested class can be created without first creating an instance of the enclosing class.
Yes, it is possible to access a field, x, of a static nested class using an expression such as OuterClassName.StaticNestedClassName.x.


Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
If x is an instance field the compiler will not allow to access it from a static context.


SCJP2. Please Indent your code using UBB Code
dragon ji
Ranch Hand

Joined: Oct 31, 2002
Posts: 110
thanx!
 
 
subject: question about static inner class?