0 votes
in Java by
What is lambda expression and how to write lambda expression in java 8?

1 Answer

0 votes
by (3.7k points)
Lambda expression:- In java 8, Lambda expression is anonymous function which have set of parameters and a lambda (->) and a function body. You can call it function without name.

See the following Structure of Lambda Expressions:-
(Argument List) ->{expression;}
(Argument List) ->{statements;}

Lambda Expression example of thread execution:-

// old way
  new Thread(new Runnable() {
   public void run() {
    System.out.println("Thread is started");
  // using lambda Expression
  new Thread(()->System.out.println("Thread is started")).start();

Share:- Whatsapp Facebook Facebook

Welcome to Developerhelpway Q&A, where you can ask questions and receive answers from other members of the community.