~/ learn/ java-from-zero/ cards/ Lambdas & Streams
1 of 28

Type a two-param lambda assigned to a BinaryOperator

Type a two-param lambda assigned to a BinaryOperator

Answer

BinaryOperator<Integer> add = (a, b) -> a + b;

BinaryOperator<T> is a functional interface whose single abstract method is apply(T, T) -> T. The compiler wires (a, b) -> a + b to that method automatically.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/9bf4ac62-e755-4d28-abb4-e97b84c794cb/flashcard utf-8 LF