~/ 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/8fa37489-d406-4464-b339-c068afe9014a/flashcard utf-8 LF