Originally posted by Bindesh:
"An inner class is a nested class that is not explicitly or implicitly declared static"
Does this mean that a nested class that is declared static is not an inner class.
And what does this mean
"Nested classes that are not inner classes may declare static members freely, in accordance with the usual rules of the Java programming language"(JLS 8.1.2).Any codes to explain this.
A non-static nested class is called an inner class. An inner class can not declare a static member unless it is a compile time constant. Even though f is final, it does not have a value at compile time and therefore it causes a compilation error. Member variable g also causes a compiler error because it is static. The static initializer of NonStaticInner causes a compiler error because inner classes can not declare static initializers.
Compiler error at line 12.
Compiler error at line 13.
Compiler error at line 15.