Java 8 Functional Interfaces Java Java API
java.util.function.BinaryOperator<T>
default <V> BiFunction<T,T,V> andThen(Function<? super R,? extends V> after)
Returns a composed function that first applies this function to its input, and then applies the after function to the result.
after
In other words the 'after' function maps the return value of this BinaryOperator<T> from type T to type V.
package com.logicbig.example.binaryoperator;import java.util.function.BiFunction;import java.util.function.BinaryOperator;public class AndThenExample { public static void main(String... args) { BinaryOperator<Integer> integerAdder = Math::addExact; BiFunction<Integer, Integer, Double> squareRootOfSum = integerAdder.andThen(Math::sqrt); Double d = squareRootOfSum.apply(7, 9); System.out.println(d); }}
4.0