The enum constant . reference cannot be qualified in a case label
Friday, April 29, 2011
by
Iori Yagami
That's a very strange error, since the solution is quiet simple : juste remove the enum class name!
As an example :
public enum DAYS {
MONDAY,
THURSDAT,
WEDNESDAT,
...;
}
When you want to use this enum as a switcher case values, like this :
switch (myValue) {you got this error :
case DAYS.MONDAY :
break;
....
}
The enum constant DAYS.MONDAY reference cannot be qualified in a case label
Seems weird, but just remvoe "DAYS" and move on.
1 comments:
This is enforced to avoid people using multiple enums in one switch statement. If MONTHS also is an enum, below will be an incorrect switch statement for sure.
e.g.:
DAYS myValue = ...;
switch (myValue) {
case DAYS.MONDAY :
break;
case MONTHS.JANUARY :
break;
}
I also discussed this here
Post a Comment