~/ learn/ java-from-zero/ cards/ Lambda syntax & effectively-final capture
1 of 4

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/d8127a47-369a-4587-bb84-e1a868c038f0/flashcard utf-8 LF