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

How to create excel sheets using Java?
HSSFWorkbook workbook = new HSSFWorkbook();HSSFSheet sheet1 = workbook.createSheet("actions");for (int i = 0; i < 10; i++) { sheet1.createRow(i); for (int j = 0; j < 10; j++) { HSSFRow currRow =...

Spring - Dependency Injection (DI)
Spring - Dependency Injection (DI) DI is a framework which provides loose coupling in code. Here loose coupling means no hard coding of the object. Instead of hard coding, we will be injecting these object...

Easy way to remember Java keyword.
ACCESS MODIFIER ACCESS SPECIFIER abstract, assert, const, final, native, static, strictfp, super, synchronized, this, transient, void, volatile public, private, protected, default DATA...

Rohit Deshbhratar

1 0
0

How do i get best Campus / Off Campus Placement?
Companies are looking for Skilled Freshers. So build your technical skills while doing MCA / BTech / BCA / BSc (IT or CS) into below areas- 1. Strong your programming & debugging skills ...

Java Overview
Java platform overview Java platform components The Java platform consists of the following components. The Java language Like any programming language, the Java language has its own structure, syntax...
A

Akshay Shende

0 0
0
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