I wonder why ToDoubleBiFunction doesn't extend BiFunction. Just how I did:
import java.util.function.BiFunction;
public class Test {
public static void main(String[] args) {
MyToDoubleBiFunction<Integer, Integer> f = (a, b) -> a.doubleValue() + b.doubleValue();
System.out.println(f.apply(1, 2));
}
}
@FunctionalInterface
interface MyToDoubleBiFunction<T, U> extends BiFunction<T, U, Double> {
}
This code works and prints 3.0
.
Also what is the point of using wordy applyAsDouble
method instead of well-known apply
?