A is an attempt to create a static nested class. A "static class" within another class is not really considered an inner class. It's legal, but a static nested class certainly has no access to instance variables in the outer class.
B is also a static nested class, and has no access to instance variables in the outer class.
The notion of an instance of the outer class has no meaning in A and B because a static nested class is tied to the outer class rather than an instance of that class. (thanks Marc for pointing that out to me
)
A nested class is is instantiated with:
Its association with the outer class is restricted to being able to access class (static) variables of the outer class, but not instance variables (fields).
C, D, and E are attempting to be inner classes. D fails during compile time because an inner class cannot have static members.
C is a nice well-behaved inner class. And E is OK because it's all right for an inner class to be abstract.
As for the qualifiers on the "class" declarations. A class declared within an outer class but outside a method can have have the following access specifiers: public, protected, private (or none at all). This makes it an inner class. If it has a modifier of static in its class declaration, it's a static nested class, and that's legal too.
(jls
8.1.2 Inner Classes and Enclosing Instances
An inner class is a nested class that is not explicitly or implicitly declared static... Inner classes may not declare static members, unless they are compile-time constant fields ...Inner classes may inherit static members that are not compile-time constants even though they may not declare them. Nested classes that are not inner classes may declare static members freely, in accordance with the usual rules of the
Java programming language.
*whew*, I don't envy Kathy and Bert's job
[ September 17, 2004: Message edited by: Louie van Bommel ]