I Help You
Programming

Lambda Expression

A lambda expression is a short, unnamed (anonymous) function written inline, usually to pass behaviour to another function: what to do with each item, how to sort, or what to run when an event happens.

Java uses (a, b) -> a + b, JavaScript has arrow functions such as (a, b) => a + b, Python has lambda a, b: a + b, and C# uses (a, b) => a + b. Lambdas are a core part of functional programming, used with map, filter, sort and stream operations, and they can capture variables from the surrounding scope as closures.

ExampleJava
List<String> names = List.of("Ravi", "Anu", "Karthik");

names.stream()
	.filter(n -> n.length() > 3)
	.map(n -> n.toUpperCase())
	.forEach(n -> System.out.println(n)); // RAVI, KARTHIK