getting compile error for diamond operator in idea

2020-01-27 07:41发布

I am getting this error while trying to compile some simple source code in idea ide.

java: diamond operator is not supported in -source 1.6 (use -source 7 or higher to enable diamond operator)

jdk is 1.7.40 from oracle

but where is this place to add this "-source 7" option?

i tried adding in ide settings but that had no effect.

4条回答
forever°为你锁心
2楼-- · 2020-01-27 07:56

Make sure that, in the Project Structure page, you have set your project language level to 7.0.

enter image description here

After you select this, you will have to reopen your project, but then your diamond operators should compile.

查看更多
叼着烟拽天下
3楼-- · 2020-01-27 07:56

Check Project Structure tab in IDEA, find the followng navigational path

Project Structure -> Project -> Project SDK

enter image description here

查看更多
Bombasti
4楼-- · 2020-01-27 08:04

Follow these steps.

Right Click on the project------>> go to Open module Settings--->
In that opening window click the Project in project settings---->
and set project SDK
查看更多
手持菜刀,她持情操
5楼-- · 2020-01-27 08:11

You need to set the project language level (default for all modules) and the module(s) language level

Project language level Module language level

查看更多
登录 后发表回答