This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: question about static inner class?
 
Similar Threads
Question about static class
no static method in inner class - why ?
doubt on Inner class
is inner class can be static . what is the purpose of inner class ??
Top-level classes