Christopher Anabo
Christopher Anabo
Senior Tech Lead
Christopher Anabo

Notes

Stream API

Stream API

stream.filter().map().collect()

public List stringTransform_upperCase(List namesList){
        return namesList
                .parallelStream()
                .map(String::toLowerCase)      // Intermediate operation
                .collect(Collectors.toList()); //Terminal operation
    }

The entire operation is called Pipeline

 

Summary Table

Interface Functional Method Signature Use Case Example
Predicate<T> boolean test(T t) Used in filter
Function<T, R> R apply(T t) Used in map
Consumer<T> void accept(T t) Used in forEach
Supplier<T> T get() Used in Stream.generate
BinaryOperator<T> T apply(T t1, T t2) Used in reduce
UnaryOperator<T> T apply(T t) Similar to Function<T, T>