aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) 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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "nested classes" Watch "nested classes" New topic
Author

nested classes

meeta gaur
Ranch Hand

Joined: Dec 05, 2012
Posts: 305


MemberTest.java:17: error: cannot find symbol
System.out.println(Nested.j);
^
symbol: variable j
location: class Nested
1 error

nested classe can have static members of enclosing class, then whats problem here ?


My one regret in life is that I am not someone else.
- Woody Allen
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8


Your Nested class does not define any variable called 'j'


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
meeta gaur
Ranch Hand

Joined: Dec 05, 2012
Posts: 305

Maneesh Godbole wrote:
Your Nested class does not define any variable called 'j'


Nested class has access of private static member j of enclosing class , then why it can't be (Nested.j) ?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

meeta gaur wrote:
Nested class has access of private static member j of enclosing class , then why it can't be (Nested.j) ?

Because the syntax Nested.j means 'j' is defined in the Nested class
meeta gaur
Ranch Hand

Joined: Dec 05, 2012
Posts: 305

Thank you
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: nested classes