NetBeans:-source 1.5 不支持菱形运算符(使用 -source 7 或更高版本启用菱形运算符) [英] NetBeans : diamond operator is not supported in -source 1.5 (use -source 7 or higher to enable diamond operator)
问题描述
我不知道为什么当我编码时:
List数据 = 新的 ArrayList();
它说
<前>-source 1.5 不支持菱形运算符(使用 -source 7 或更高版本来启用钻石运算符)----(Alt-Enter 显示提示)我已经在使用 JDK 1.7.当我在 eclipse 中打开它时,我没有收到那个错误.
-source 1.5
意味着您的代码将与 Java 1.5 版兼容,并且不能使用稍后引入的语言结构.阅读 http://docs.oracle.com/javase/8/docs/technotes/tools/unix/javac.html 以了解更多信息.
实现您想要的(能够使用在 Java 7 中添加的菱形运算符)的简单方法是在项目定制器中更新项目源/二进制版本 - 转到 Projects
选项卡(Ctrl-1),选择项目节点,在其上下文菜单中选择 Properties
并更新 Source 选项卡中的 Source/Binary Format
字段.
I don't know why when I code:
List<String> data = new ArrayList<>();
it said that
diamond operator is not supported in -source 1.5 (use -source 7 or higher to enable diamond operator) ---- (Alt-Enter shows hints)
I already use JDK 1.7. When I opened it in eclipse, I didn't get that error.
-source 1.5
means your code will be compatible with Java version 1.5 and cannot use language constructs introduced later. Read http://docs.oracle.com/javase/8/docs/technotes/tools/unix/javac.html to find more.
Easy way to achieve what you want (to be able to use diamond operator added in Java 7) is to update project source/binary version in project customizer - go to Projects
tab (Ctrl-1), select project node, choose Properties
in its context menu and update Source/Binary Format
field in Source tab.
这篇关于NetBeans:-source 1.5 不支持菱形运算符(使用 -source 7 或更高版本启用菱形运算符)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!