If you wana use enums in a switch, don't google, I did...
Enum switch case label must be the unqualified name of an enumeration constant.
So let's understand this with a simple example:
This looks fine, so? Unfortunately, it is wrong in two different ways.
The case exp should be without the brackets and only INT should be used without the EnumType type def. Let's illustrate within a simple correction:
Summarization:
* In case statement the enum must be used without brackets.
* In case only the unqualified enum name must be used.
Enum switch case label must be the unqualified name of an enumeration constant.
So let's understand this with a simple example:
enum EnumType { INT,DATE, FLOAT}
EnumType someVar;
...
switch (someVar) {
case (EnumType.INT):
handle(EnumType.INT);
...
}
This looks fine, so? Unfortunately, it is wrong in two different ways.
The case exp should be without the brackets and only INT should be used without the EnumType type def. Let's illustrate within a simple correction:
switch (someVar) {
case INT:
handle(EnumType.INT);
...
}
Summarization:
* In case statement the enum must be used without brackets.
* In case only the unqualified enum name must be used.