Java 在idea ide中获得菱形运算符的编译错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21747254/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 10:28:08  来源:igfitidea点击:

getting compile error for diamond operator in idea ide

javaintellij-ideadiamond-operator

提问by Ashish Yadav

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

尝试在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

jdk 是 oracle 的 1.7.40

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

但是这个地方在哪里添加这个“-source 7”选项?

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

我尝试添加 ide 设置,但没有效果。

回答by Abimaran Kugathasan

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

检查 IDEA 中的项目结构选项卡,找到以下导航路径

Project Structure-> Project-> Project SDK

Project Structure-> Project->Project SDK

enter image description here

在此处输入图片说明

回答by Abimaran Kugathasan

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

您需要设置项目语言级别(所有模块的默认值)模块语言级别

Project language levelModule language level

项目语言水平模块语言级别

回答by Makoto

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

确保在“项目结构”页面中,您已将项目语言级别设置为 7.0。

enter image description here

在此处输入图片说明

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

选择此选项后,您将不得不重新打开您的项目,但您的钻石操作符应该会编译。

回答by Ruchira Gayan Ranaweera

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