IntelliJ switch statement using Strings error: use -source 7

天大地大妈咪最大 提交于 2019-12-01 03:21:10

At the Intellij IDEA you should also go to Project Settings -> Project and set appropriate Project language level there

In case anyone still gets this error message after following the advice to check the File > Project Structure -> Project and set appropriate Project language level.

Be sure to also check File > Project Structure> Modules, to see if all your modules are on the correct Language Level: (or the specific desired level).

There is also one more place where this can go wrong, which is: File > Settings > Compiler > Java Compiler. There you can set the project and module's java compiler version.

(For IntelliJ version <= 12 : Project Structure => Project Settings)

Remember that using Strings in switch statements is only supported from JDK 1.7 onwards. The default project settings of IntelliJ might not be using JDK 1.7 as default. Change them from the project settings to JDK 1.7.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!