It is a compile-time error to reference a static field of an enum type that is not a compile-time constant (�15.28) from constructors, instance initializer blocks, or instance variable initializer expressions of that type.
In your example you need to add 'final' to the static variable declaration to make it a compile- time constant and hence be able to use it in an init block.
Joined: Nov 06, 2007
Ahmed Yehia, you are right, but in Test1 class 'test' is not final, and this class compiles without errors anyway. Why? I don't know answer.
Joined: Apr 22, 2006
'Test1' doesn't compile for the same reason, same rule apply.