[英]NetBeans : diamond operator is not supported in -source 1.5 (use -source 7 or higher to enable diamond operator)
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. 我已经使用JDK 1.7了。 When I opened it in eclipse, I didn't get that error.
当我在eclipse中打开它时,我没有得到那个错误。
-source 1.5
means your code will be compatible with Java version 1.5 and cannot use language constructs introduced later. -source 1.5
意味着您的代码将与Java 1.5版兼容,并且不能使用稍后介绍的语言结构。 Read http://docs.oracle.com/javase/8/docs/technotes/tools/unix/javac.html to find more. 阅读http://docs.oracle.com/javase/8/docs/technotes/tools/unix/javac.html以了解更多信息。
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. 实现您想要的简单方法(能够在Java 7中添加钻石运算符)是在项目定制器中更新项目源/二进制版本 - 转到“
Projects
选项卡(Ctrl-1),选择项目节点,在其中选择“ Properties
上下文菜单并更新“源”选项卡中的“ Source/Binary Format
字段。
You missed this: 你错过了这个:
List< String > data = new ArrayList< String >(); List < String > data = new ArrayList < String >();
You have to put "String" in both "<>" 你必须在“<>”中加入“String”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.