Language
Lambda capture
A captured local must be final or effectively final and definitely assigned. Referenced objects need not be immutable.
Formal Syntax & Structure
java syntaxjava
int limit = 5; IntPredicate p = n -> n >= limit;Working Example
Example Snippetjava
import java.util.*;import java.util.function.*;public class Main {
public static void main(String[] args) { int minimum = 5; IntPredicate enough = units -> units >= minimum; System.out.println(enough.test(4)); System.out.println(enough.test(5)); }}