Empty enum declartions are allowed where other static declarations are not
Tried on Tiger-Beta3-Build 59, solaris
Please See the code below:-
/**Empty enum declarations are allowed where other
*static declarations are not allowed.
*/
import java.util.*;
class B {
}
class A {
enum COLOR{RED, GREEN};
public B check() {
//enum CHECK{}; ->compilation error enum types must not be local
return new B() {
//static int k =0; -> Compilation error static inside inner class
//public static void show() {} -> compilation error static inside inner class
enum STRENGTH{}; // compiles silently
//enum STRENGTH{HARD,SOFT}; // gives compilation error non static variable this cannot be refrenced from a static context
};
}
}
public class Test16 {
public void assertion() {
A ref_A = new A();
B ref_B = ref_A.check();
}
public static void main(String args[]) {
Test16 ref = new Test16();
ref.assertion();
}
}