Inner class and static members

Hi, I know that a non-static inner class can not have static members. But the following code compiles successfully and I am confused at it.

class MyOuter

{

MyInner inner = new MyInner();

class MyInner

{

//private static int[] arr1 = new int[2];

//private static int a1 = 5;

//private static final int[] arr2 = new int[2];

private static final int a2 = 5;

}

}

This class compiles successfully though it does not do anything. Here a2 has been declared both static and final and compiler does not object to that whereas if I uncomment any of the commented declarations, the compiler shows errors. Please tell me what is the problem over here.

[718 byte] By [maitya] at [2007-11-27 2:17:16]
# 1
The rule is that inner classes may not declare static members, unless they are compile-time constant fields. http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#5313
YoGeea at 2007-7-12 2:15:40 > top of Java-index,Java Essentials,Java Programming...
# 2
Thanks a lot YoGee. It was great to learn the fact that compile-time constants can be declared in non-static classes.
maitya at 2007-7-12 2:15:40 > top of Java-index,Java Essentials,Java Programming...