aspose file tools*
The moose likes Beginning Java and the fly likes Inner class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Inner class" Watch "Inner class" New topic
Author

Inner class

shree vijay
Ranch Hand

Joined: Sep 18, 2000
Posts: 208
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.


Regards,<BR>Shree
John Wetherbie
Rancher

Joined: Apr 05, 2000
Posts: 1449
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.

The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai
John Wetherbie
Rancher

Joined: Apr 05, 2000
Posts: 1449
You may want to check out this thread which discusses this point:
http://www.javaranch.com/ubb/Forum10/HTML/000092.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inner class