This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
Inner and Nested Top Level Classes
Posted by Bill Venners on April 20, 2000 at 4:34 AM
> Hai, > I want to know what is static and non-static classes along with clear examples. What you are calling "static classes" are most likely "nested top-level classes," which are declared with the static keyword. These contrast with plain old top level classes, which aren't declared inside any other class (are members of a package), and inner classes, which are declared inside other classes, but without the static keyword. Nested top-level classes act basically the same as regular old top-level classes, except that they have longer fully qualified names and they can have any of the four access levels assignable to class members: private, public, protected, or package. The fully qualified name of a nested top-level class includes the names of each of its enclosing classes. Inner classes are compiled specially in that they receive a reference to an enclosing class instance. This is hard to describe in a brief paragraph. I'd suggest you study a chapter, article, or tutorial on the subject. I have a seminar handout with examples which may help you visualize what a "reference to an enclosing class instance" is, though the handout has little supporting text: http://www.artima.com/javaseminars/modules/InnerClasses/index.html bv
Replies:
|