Today I found myself coding for something like this ...
public class LocalEnums { public LocalEnums() { } public void foo() { enum LocalEnum { A,B,C };
and I was surprised when the compiler reported an error on the local enum :
Member enum LocalEnum cannot be local
Why can't enums be declared locally, for example classes ?
I found this very useful in certain situations. In the case where I was working, the rest of the code did not need an enum value.
Is there any construct / construct conflict that explains why this is not possible, or could this be a future Java feature?
java enums
bruno conde Mar 31 '09 at 13:02 2009-03-31 13:02
source share