• Post Reply Bookmark Topic Watch Topic
  • New Topic

Nested classes  RSS feed

 
Faisal syed
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!