this is from the JLS:
An inner class is a nested class that is not explicitly or implicitly declared static.
static classes declared inside another class are referred to as a nested classes.
it is created at compile time and does not have any refernce to Outer class. So it cannot access outer class members unless otherwise those members declared with static keywords. static inner classes can be refered wihout outer class reference since it is created at compiled time.
Inner classes can not be static .it is very true. jls states that any class which is in direct scope of other class (& is static) is a top level class.although it is inside of scope of another class.Hope this clears the doubts.
Originally posted by ego hu:
Innner class can be static?
As I remember that some mock exam said that the inner class
can not be static, but some other mock exam said it is
possibe? Who is righ?
Maybe, the inner class defined in a non-static method
can not be static.
Who knows the answer?
Check this out for a referance document about inner classes
I hope this helps.
(B.s. Computer Engineer)