W3Schools Learner's Blog

W3Schools Programming knowledge summary website

div

12/04/2017

the usage example of BiFunction interface

BiFunction<T, U, R> are the interfaces in the java8 function, and the meaning of the 3 parameters , as follows.
T -  parameter one
U - parameter two
R - result

There are two methods in the BiFunction interface, as follows.
//andThen will be executed last
default <V> BiFunction<T,U,V> andThen(Function<? super R,? extends V> after)

R apply(T t, U u)
BiFunction usage example, as follows.
import java.util.function.BiFunction;
import java.util.function.Function;

public class TestDemo {
 public static void main(String[] args) {
  BiFunction<String, String,String> biFunction = (x, y) -> {
      return x+"==="+y;

  };

      Function<String,String> fun = x ->x + " after8";
      System.out.println(biFunction.andThen(fun).apply("tpyyes.com ", " java8"));
 }
}
output String.
tpyyes.com === java8 after8

No comments:

Post a Comment

Note: only a member of this blog may post a comment.