Stream API & Lambdas
Declarative data processing and functional interfaces.
Pipeline shape
list.stream() // source .filter(x -> x > 0) // intermediate .map(x -> x * 2) // intermediate .toList(); // terminal
Common operations
filter(pred)
keep matchingmap(fn)
transform eachreduce(0, Integer::sum)
combine to onesorted() / distinct() / limit(n)
count() / findFirst() / anyMatch(pred)
Collectors
collect(Collectors.toList())
Collectors.groupingBy(X::key)
Collectors.joining(", ")Collectors.averagingInt / summingDouble
Functional interfaces
Function<T,R>
T -> RPredicate<T>
T -> booleanConsumer<T>
T -> voidSupplier<T>
() -> TString::length
method reference