Using NetBeans 8 but getting below compilation error for Lambda expression

六月ゝ 毕业季﹏ 提交于 2019-11-28 07:40:45

问题


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)

回答1:


Change compiler version of your source code into your project properties to jdk 8 and firstly check whether you have installed one.




回答2:


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




回答3:


In the project properties dialog, select Sources in the left panel and then on the bottom right look for "Source/Binary Format" Change that to JDK 8.




回答4:


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.



来源:https://stackoverflow.com/questions/22686174/using-netbeans-8-but-getting-below-compilation-error-for-lambda-expression

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!