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)

查看:169
本文介绍了NetBeans:-source 1.5不支持菱形运算符(使用-source 7或更高版本启用菱形运算符)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在编码时不知道为什么:

I don't know why when I code:

List<String> data = new ArrayList<>();

它说


diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)
----
(Alt-Enter shows hints)

我已经使用了JDK 1.7。当我在eclipse中打开它时,我没有得到那个错误。

I already use JDK 1.7. When I opened it in eclipse, I didn't get that error.

推荐答案

-source 1.5 表示您的代码将与Java 1.5版兼容,并且不能使用稍后介绍的语言结构。阅读 http://docs.oracle.com/javase/8/docs/technotes /tools/unix/javac.html 以查找更多信息。

-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.

轻松实现您想要的方式(能够在Java 7中添加钻石运算符) )是在项目定制器中更新项目源/二进制版本 - 转到项目选项卡(Ctrl-1),选择项目节点,选择属性在其上下文菜单中,并在源选项卡中更新源/二进制格式字段。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆