UrbanPro
true

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Lambda Expressions in Java

Ashish Somvanshi
16/04/2021 0 0

A lambda expression, introduced in Java 8 is similar to a block of code resembling an anonymous function that can be passed to constructors or methods for execution as an argument.

Examples:

a)() -> System.out.println("Hello Lambda")
b)
(int x) -> 3
x -> {
System.out.println(x + 2);
return x +3;
}

In the first example :

() identifies the lambda's parameter list (there are no parameters),

 -> indicates that the expression is a lambda

System.out.println("....") is the code to be executed which prints the string "Hello Lambda".

In the Second Example:

(x) identifies the lambda's parameter list (x is an input parameter),

 -> indicates that the expression is a lambda

System.out.println("....") is the code to be executed which calculates the value of x + 2 and prints it. Also assigns a value of x+3 = 6 to variable x which had an initial value of 3.

0 Dislike
Follow 1

Please Enter a comment

Submit

Other Lessons for You

Final modifier in Java
Can’t change value of variable if marked as final. It is best practice to mark method parameter as final if its value will not changes. Variable must be initialize either using Initializer block...


CONDITIONAL STATEMENT - IF ELSE
1. IF condition only if is true conditon is required. if(condition){//statements} 2. IF-ELSE condition 1. to check whether the condition will be true or false.syntax of if-else2. only 1 conditionif(condition){//statements}else{//statements} 3....

On the Job training is always best
On the job training always provides an opportunity to learn the best industry practices. While you work on real time you would encounter many challenges that will force you to learn many new things. Class...
M

jOOQ 3.10 Supports JPA Attribute Converter
One of the cooler hidden features in jOOQ is the JPADatabase, which allows for reverse engineering a pre-existing set of JPA-annotated entities to generate jOOQ code. For instance, you could write these...
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more