For this question:
Which functional interfaces can fill in the blanks to make the code compile? (Choose all that apply.)
5: public void doubles(______ x, ________ y, ________ z) {
6: double d1 = x.applyAsDouble("");
7: double d2 = y.applyAsDouble(1L);
8: z.accept(1.0);
9: }
The answer are:
A. Consumer<Double>
B. DoubleConsumer
C. Function<Long, Double>
D. Function<String, Double>
E. LongToDoubleFunction
F. ToDoubleFunction<String>
I am having a hard time understanding why DoubleConsumer is not acceptable.
DoubleConsumer's SAM is accept() and it takes a double.
What am I missing?
Thank you in advance,
Will