枚举 switch case 标签必须为枚举常量的非限定名称

枚举 switch case 标签必须为枚举常量的非限定名称

错误描述:

Error:(63, 24) 错误: 枚举 switch case 标签必须为枚举常量的非限定名称。

解决思路:

switch语句支持使用枚举类型作为条件

case标签支持:

1.类型为char、byte、short、int的常量表达式

2.枚举常量

3.从jdk7开始,支持字符串

这是我出错的代码:

枚举 switch case 标签必须为枚举常量的非限定名称

枚举定义:

枚举 switch case 标签必须为枚举常量的非限定名称

代码错误提示:

发现case后报错 :an enum switch case label must be the unqualified name of an enumeration constant

意思是:枚举 switchcase 标签必须为枚举常量的非限定名称,其实就是不能加类名

正确的写法:

枚举 switch case 标签必须为枚举常量的非限定名称