• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Inner class

 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Here is a question and answer from the Rules Round up.
True or False:
A static inner class (considered as a top-level nested class) CANNOT access non-static variables of the outer class.
Answer:
TRUE. A static inner class is treated as a top level nested class and has no reference -- no special relationship -- to any instance of the enclosing class.
I don't quite get the point when they say a static inner class is treated as a top level nested class. From what i understand , a top level nested class is the outermost class in a nested class construct. I understand the point of the static nested class not being able to relate to the instances.
 
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you are calling of as a top level nested class is just a top level class. Static inner class is the term that Sun used (and still may be using) to describe an inner class that is static. But a more understandable name for a static inner class is top level nested class because while the class is nested it is treated as a top level class.
 
John Wetherbie
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may want to check out this thread which discusses this point:
http://www.javaranch.com/ubb/Forum10/HTML/000092.html
 
Maybe he went home and went to bed. And took this tiny ad with him:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic