1.

Why Lambda Expression Is To Be Used?

Answer»

Lambda EXPRESSIONS are used primarily to define inline implementation of a functional interface, i.e., an interface with a single method only. In the above example, we've used VARIOUS types of lambda expressions to define the operation method of MathOperation interface. Then we have DEFINED the implementation of sayMessage of GreetingService.

Lambda expression eliminates the need of anonymous class and gives a very SIMPLE yet powerful functional programming capability to Java.

Lambda expressions are used primarily to define inline implementation of a functional interface, i.e., an interface with a single method only. In the above example, we've used various types of lambda expressions to define the operation method of MathOperation interface. Then we have defined the implementation of sayMessage of GreetingService.

Lambda expression eliminates the need of anonymous class and gives a very simple yet powerful functional programming capability to Java.



Discussion

No Comment Found