Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

enabling the lambda expression

Tags:

java

java-8

In the program like

entities.stream().filter(m->m.getId()==id).findAny().get();

where entities is a List. After setting all the libraries and other SDKs to Java 8. we are getting the error as:

use -source 8 or higher to enable lambda expressions
like image 604
sagari Avatar asked Apr 03 '14 12:04

sagari


People also ask

Why it is important to enable the usage of lambda expressions?

Easy-to-Use APIs and Libraries: An API designed using lambda expressions can be easier to use and support other API. Enables support for parallel processing: A lambda expression can also enable us to write parallel processing because every processor is a multi-core processor nowadays.

What is lambda expression?

A lambda expression is a short block of code which takes in parameters and returns a value. Lambda expressions are similar to methods, but they do not need a name and they can be implemented right in the body of a method.

Where is lambda expression?

Java lambda expressions are commonly used to implement simple event listeners / callbacks, or in functional programming with the Java Streams API. Java Lambda Expressions are also often used in functional programming in Java .


1 Answers

This is how solved my problem by adding the below plugin settings in my parent POM file.

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>
like image 200
sagari Avatar answered Oct 20 '22 04:10

sagari