简体   繁体   中英

Using NetBeans 8 but getting below compilation error for Lambda expression

I am using NetBeans 8. When my code contains a Lambda expression and I try to compile, I get the following error message:

lambda expression not expected here

lambda expressions are not supported in -source 1.5
  (use -source 8 or higher to enable lambda expressions)
----
(Alt-Enter shows hints)

Please click right from you project -> Properties -> Choose Sources -> (you will see Source/Binary Format) change it to 1.8 -> Click OK.

Or you can see in this link http://tinadev.blogspot.com/2015/08/lambda-expression-not-expected-here.html

Thanks

对于NetBeans IDE 8.2,JDK 8

将源代码的编译器版本更改为项目属性为jdk 8,并首先检查是否已安装。

在项目属性对话框中,在左侧面板中选择“源”,然后在右下角查找“源/二进制格式”,将其更改为JDK 8。

Download JDK 1.8 to resolve this issue. change the JAVA_HOME environment variables path to jdk_1.8. Right Click on the project folder which has the above mentioned compilation error and select properties. In Sources tab change the source/binary format to JDK 8. In libraries change Java Platform to JDK 1.8.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM