What are the three main parts of a Lambda expression in Java?

Three main parts of a Lambda expression are:

  • Parameter list: A Lambda expression can have zero or more parameters. Parameter list is optional to Lambda.
  • Lambda arrow operator: “->” is known as Lambda arrow operator. It separates the list of parameters and the body of Lambda.
  • Lambda expression body: The piece of code that we want to execute is written in Lambda expression body.

E.g. In following example:

Arrays.asList( “a”, “b”, “d” ).forEach( e -> System.out.println( e ) );

Parameter list = e
Arrow = ->
Body = System.out.println( e )

Read the full book at www.amazon.com
Posted in Java 8, Java 8 Interview Questions

Leave a Reply

Your email address will not be published. Required fields are marked *

*