Posts

Showing posts from January, 2020

Quick Reference: Predefined Interfaces for Lambda Expression

At the time of writing, the java.util.function package provides 43 Interfaces to use with Lambda Expression and other purposes.  Those predefined interfaces are often enough to cover common needs.  While there are 43 of them, most are derivatives of the primary forms. For example, Consumer<T> has these derivatives: BiConsumer<T,U> DoubleConsumer IntConsumer LongConsumer ObjDoubleConsumer<T> ObjIntConsumer<T> ObjLongConsumer<T> Those Interfaces are different but their concept is the same.  Given that the Interfaces can be organized into different concept groups, it is good to remember the primary form of each group.  Here is a quick reference. Consumer<T> Abstract method: void accept(T t) Accept an operation on an object of type T , and return no result. Function<T,R> Abstract method: R apply(T t) Apply an operation to an object of type T , and return the result in type R . Predicate<T> Abstract me...