This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Nested classes" Watch "Nested classes" New topic
Author

Nested classes

Faisal syed
Ranch Hand

Joined: Mar 25, 2011
Posts: 35
Hello Friend,
As per an oracle documentation put at http://docs.oracle.com/javase/tutorial/java/javaOO/nested.html

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




However, the above code contradicts the statement.

Please comment.

Thanks
Faisal
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7553
    
  18

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.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Nested classes
 
Similar Threads
class types
Why Class cannot be declared as static ?
Where Can I Read about Non-Static Inner Classes?
static class accessing VERY internal question
Local Inner Class