Java Stream How to - Create BiFunction with Lambda








Question

We would like to know how to create BiFunction with Lambda.

Answer

//ww  w .java 2 s .c  o m
import java.util.function.BiFunction;

public class Main {

  public static void main(String[] args) {
    BiFunction<String, String, String> biFunction = (s1, s2) -> s1 + s2;

    String result = biFunction.apply("Just", "Java 8");
    System.out.println("Result: " + result);
  }

}

The code above generates the following result.