Lambda
🔹 1. What is a Lambda Expression?
A Lambda Expression is essentially an anonymous function
— a function without a name — that can be passed as a
parameter or stored as a variable.
(parameters) -> expression
(parameters) -> { statements }
(int a, int b) -> a + b
This expression takes two integers and returns their sum.
🔹 2. Why Use Lambdas?
More concise code.
Enables functional programming in Java.
Useful in collections, streams, event handling, etc.
Eliminates boilerplate code (like anonymous inner
classes).