File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Nested classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Nested classes" Watch "Nested classes" New topic

Nested classes

Faisal syed
Ranch Hand

Joined: Mar 25, 2011
Posts: 35
Hello Friend,
As per an oracle documentation put at

Static nested classes do not have access to other members of the enclosing class

However, the above code contradicts the statement.

Please comment.

Winston Gutkowski

Joined: Mar 17, 2011
Posts: 8837

Faisal syed wrote:Static nested classes do not have access to other members of the enclosing class

"Members" generally refers to non-static fields. Take the static off the var definition and see how far you get.


Bats fly at night, 'cause they aren't we. And if we tried, we'd hit a tree -- Ogden Nash (or should've been).
Articles by Winston can be found here
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

And like static class methods, a static nested class cannot refer directly to instance variables or methods defined in its enclosing class
— it can use them only through an object reference

From the reference what you have given.
I agree. Here's the link:
subject: Nested classes
It's not a secret anymore!