JDK1.8后switch case不支持String的解决方法

在JDK1.7后,switch case支持String类型参数,

但是我在使用IDEA时,出现了问题,提示case不支持String。

但我在项目结构中选择的是JDK1.8版本,

后来发现,在左侧的Project视图的根目录中,项目名.iml文件中的

<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">

这里显示JDK1.5。

解决方法:
File | Settings | Build, Execution, Deployment | Compiler | Java Compiler,把项目的JDK版本改成自己想要的版本

posted on 2017-07-07 17:44  theLazarus  阅读(1409)  评论(0编辑  收藏  举报