An anonymous function, commonly called a lambda, is a function value without a declared name. It can be passed, stored, returned, or invoked as data. In Java, a lambda implements a functional interface: an interface with one abstract method. section 6.2 section 6.2.1
From boilerplate to behavior
A named class can express the rule that a string must exceed three characters, but it adds ceremony around one method. A lambda keeps the behavior: `StringPredicate myTestingFunction = x -> x.length() > 3;`. The arrow separates parameters from the body, while the target functional-interface type supplies the expected signature. section 6.2 section 6.2.1
Use lambdas as compact behavior, but choose explicitness when compression increases cognitive load:
- Pass them to functions, store several alternatives in a collection, or return them from a method. section 6.2.1
- Prefer a lambda over a method reference when explicit parameters make the operation easier to understand. section 5.2
- Prefer a loop or extracted method when a lambda or pipeline hides too many steps, especially around exception handling. section 5.2 section 6.5
StringPredicate myTestingFunction = x -> x.length() > 3;
boolean isValid = myTestingFunction.test("hello");
Compare the compact Java lambda with equivalent forms in Kotlin, C#, Python, and Haskell through the surrounding examples. section 6.2.1

















