Hello Anuji
Your first post is answered by JLS 8.1.2
Inner classes may not declare static members, unless they are compile-time constant fields (�15.28).
Also "public static final double i = Math.random();" is not a valid member of an inner class because the invocation of a method is not included in JLS 15.28
To see why only static final fields, that are initialized to a compile constant (JLS 15.28), are the only static valid members for an inner class look at the output of javap for the following code.
In line 3 the value 3 is passed to the print method via an iconst_3 bytecode instead of looking for the content of the field x. Each time an access to such field ocurrs iconst_3 will be used. Why? because it is not possible for an inner class to hold a static field.
Similarly in line ten, the value 58888 is passed to the print method via a ldc #5 bytecode. Given that the value of y is known at compile time as constant, compiler doesn't use a bytecode that access the value of a field y that is static, and thefore not possible in an inner class. Compiler uses a ldc #5 bytecode each time the value of y is needed. This bytecode gets the value (58888) that is stored in the entry 5 in the constant pool of the class Outer.Inner.
It follows that the values from compile constants are retrived in ways that avoid the use of fields in the object. They are stored in the constant pool or are assigned directly by a bytecode like iconst_3.
Thus static fields in inner classes are not created.