Inside a Java enumerated class, I\'d like to create a final static
array containing the values()
of the class. When I do this along the following lines
Can you provide an example where this happens because it shouldn't be null.
public class Main {
public enum Name {
E1( ), E2( );
private static final Name[] VALUES = Name.values();
}
public static void main(String... args) {
System.out.println(Name.VALUES);
System.out.println(Arrays.asList(Name.VALUES));
}
}
prints
[LMain$Name;@717e5fde
[E1, E2]