0 votes
394 views
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;}
Or
(Argument List) ->{statements;}

Lambda Expression example of thread execution:-

// old way
  new Thread(new Runnable() {
   
   @Override
   public void run() {
    System.out.println("Thread is started");
   }
  }).start();
 
  // 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.

Categories

...