Today, I found myself coding something like this ...
public class LocalEnums {
public LocalEnums() {
}
public void foo() {
enum LocalEnum {
A,B,C
};
// ....
// class LocalClass { }
}
}
and I was kind of surprised when the compiler reported an error on the local enum
:
The member enum LocalEnum cannot be local
Why can't enums be declared local like classes?
I found this very useful in certain situations. In the case I was working, the rest of the code didn't need to know anything about the enum
.
Is there any structural/design conflict that explains why this is not possible or could this be a future feature of Java?