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

Core Java
Introduction: An Object Oriented Programming Language consists of Objects. There are object oriented programming languages like Smalltalk, C++. Each and every OOP language has some underlying disadvantages....

Difference Of Inheritance In C++ And Java
In Java , multiple inheritance is not applicable directly but we can implement the concept by using the interfaces. In c++ and Java, the common types of inheritances are: Single Multi level Hybrid Hierarchical

Free selenium video tutorial
Hi All, Hope you are doing good. We uploaded few videos on Selenium components like IDE, RC and Webdriver on youtube channel you can watch them for free of cost. Kindly search with below link: ...
S

Syntax and example of java
Java syntax: Class Display - - class definition { Void Display() { System.out.println('welcome to Java') ; } Public static void main(String arcs) { Display D=new Display() ;--object creation D. Display } }

Android : Application Launch time improvements.
For any standard android application, below 3 components play important roles to show 1st interface to user, so that he/she can interact with the app. 1. Custom Application class : Intialize the components...
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