I have come to know that inner classes in java cannot have static members unless and until they are declared final . But shouldn't it be theoretically possible to declare static members in a local class ?
Eg.
public class OuterClass
{
class innerClass
{
public static int i = 1;
// inner class code goes here
}
}
I know that standard initialisation of inner class occurs like this :
OuterClass outerClass = new OuterClass();
OuterClass.innerClass innerclassInstance = outerClass.new innerClass();
But why not this way??
OuterClass outerClass = new OuterClass();
outerClass.innerClass innerclassInstance = new outerClass.innerClass();
When ever an instance of OuterClass is created , it also contains a copy of innerClass. So if static(just static but not final ) members were allowed to be present in innerClass , then they should be( or can be) accessed this way
outerClassInstance.innerClass.member
Am I thinking in the wrong direction ? Is there any particular reason why inner classes were designed in the way they are ?
Hope I am clear . Sorry for my poor English.