What are block lambda expressions in Java?

A lambda block states that lambda expression with multiple statements. It expands the type of operations to perform with a lambda expression. The multiple statements containing bodies are called expression bodies. A lambda expression with expression bodies is called expression lambdas. Whenever we are using expression lambdas, explicitly use a return statement to return a value.


interface NumberFinder {
   int finder(int number1, int number2);
public class LambdaNumberFinder {
   public static void main(String args[]) {
      NumberFinder numberFinder = (number1, number2) -> {
         int temp = 0;
         if(number1 > number2) {
            temp = number1;
         } else {
            temp = number2;
         return temp; // explicitly return a value
      System.out.println("The valus is : " + numberFinder.finder(10, 5));


The valus is: 10

Updated on: 10-Jul-2020


Kickstart Your Career

Get certified by completing the course

Get Started