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

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

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

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

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

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

这里显示JDK1.5。io

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

相关文章
相关标签/搜索