2. Java Lambda Expressions
Lambda Expressions were added in Java 8.
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.
3. Java Lambda Expressions
Java Lambda Expressions are Java’s first step into
Functional Programming.
It is an Anonymous function that doesn’t have a
name and doesn’t belong to any class.
It Provides a clear and concise way to represent a
method interface via an expression
It provides the implementation of a Functional
Interface & Simplifies the software development.
4. Syntax
The simplest lambda expression
contains a single parameter and an
expression:
parameter -> expression
5. Syntax
To use more than one parameter, wrap
them in parentheses:
(parameter1, parameter2) -> expression
7. Functional Interface
Functional Interface is an interface
that contains exactly one abstract
method.
It can have any number of default or
static methods along with object class
methods.
Java provides pre-defined functional
interfaces to deal with the functional
programming.
Runnable, ActionListener,
Comparable are some of the
8. Here are just a few of the key
benefits to using lambda
expressions in Java:
Conciseness.
Reduction in code bloat.
Readability.
Elimination of shadow variables.
Encouragement of functional programming.
Code reuse.
Enhanced iterative syntax.
Simplified variable scope.