Skip to content

Instantly share code, notes, and snippets.

@nkalra0123
Created January 19, 2020 06:24
Show Gist options
  • Save nkalra0123/83d9858c7f1224f81753d8758ebd6456 to your computer and use it in GitHub Desktop.
Save nkalra0123/83d9858c7f1224f81753d8758ebd6456 to your computer and use it in GitHub Desktop.
BinaryOperator Functional Interfaces
// BinaryOperator
System.out.println("binaryOpeartor = " + Stream.of(1,2,3,4).reduce(new BinaryOperator<Integer>() {
@Override
public Integer apply(Integer x, Integer y) {
return x + y;
}
}).get());
System.out.println("binaryOpeartor = " + Stream.of(1,2,3,4).reduce((x, y) -> x + y).get());
System.out.println("binaryOpeartor = " + Stream.of(1,2,3,4).reduce(Integer::sum).get());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment