tfancy2012 2016-03-07 03:51 采纳率: 71.4%
浏览 11453

Cannot switch on a value of type String

编译报错,Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum constants are permitted

编译器已经是1.7的了

jdk安装的是1.7的,为什么还报这样的错误,求解

MyEclipse 报错:(虽然有显示乱码,但是已经把项目那些设置成UTF-8格式的了)
An error occurred at line: 160 in the jsp file: /module/tool/hsCode/detail.jsp
Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum constants are permitted
157: <%
158: for(char c: code.getInspection().trim().toCharArray()){
159: String key = String.valueOf(c);
160: switch(key){
161: case "M":
162: out.println("杩涘彛鍟嗗搧妫?獙");
163: break;

Stacktrace:

图片说明

  • 写回答

5条回答

  • 把分全给哥 2016-03-07 03:57
    关注

    不能用字符串当作值,得转化成数值类型或枚举类型

    评论

报告相同问题?

悬赏问题

  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算