枚举 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 标签必须为枚举常量的非限定名称

相关文章:

  • 2022-12-23
  • 2021-05-22
  • 2021-07-17
  • 2021-06-16
  • 2022-12-23
  • 2022-12-23
  • 2021-07-09
  • 2022-12-23
猜你喜欢
  • 2022-02-23
  • 2021-12-09
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2022-03-05
相关资源
相似解决方案