BiFunction represents a function that accepts two arguments and produces a result.
T — the type of the first argument to the function
U — the type of the second argument to the function
R — the type of the result of the function
Örnek
Şöyle yaparız
public class DistinctBiFunction implements
BiFunction<List<Integer>,List<Integer>,List<Integer>>{
@Override
public List<Integer> apply(List<Integer> list1, List<Integer> list2) {
return Stream.of(list1, list2)
.flatMap(List::stream)
.distinct()
.collect(Collectors.toList());
}
}
BiFunction biFunction = new DistinctBiFunction();
List<Integer> list1 = ...
List<Integer> list2 = ...
System.out.println("Output for BiFunction : " + biFunction.apply(list1, list2));
Hiç yorum yok:
Yorum Gönder