No inner class can have a static member.
No Inner class can have static members unless they are compile time constant fields.
Try to compile this:
class OuterClass{
class InnerClass{
static final int x = 23;
}
}
My question is what if I have a inner class inside a static method...or a static inner class...
arent the members of such static inner classes automatically static?
If you have a inncer class inside a static method, the inner class is not automatically static, this inner class is like any other objet made with the new operator, because you're declaring this, making an instance as any common class.
Try to compile this:
class OuterClass2 {
static void holdAInner() {
class InnerClass {
public void doSomething() {
System.out.println(".....");
}
}
InnerClass iObject = new InnerClass();
iObject.doSomething();
}
}
Regards...
[ April 24, 2007: Message edited by: Victor Velazquez ]