~/ 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/e17f6566-5fd0-4dc0-a6b0-8b23459362fb/flashcard utf-8 LF