Given the code fragment:
List
DoubleFunction funD = d ""> d + 100.0;
doubles.stream (). forEach (funD); // line n1 doubles.stream(). forEach(e ""> System.out.println(e)); // line n2
What is the result?
Given the code fragment:
List
DoubleFunction funD = d ""> d + 100.0;
doubles.stream (). forEach (funD); // line n1 doubles.stream(). forEach(e ""> System.out.println(e)); // line n2
What is the result?
A
Answer is D. forEach is a void method however DoubleFunction return double values
Answer is D
forEach takes consumer not function
Sorry I meant Answer is D
D is answer. Tested, forEach accepts Consumer or BiConsumer.
line n1 ->> doubles.stream().map(x -> funD.apply(x)).forEach(System.out::println);
D,tested.Required type Consumer,provided DoubleFunction on line 1-forEach (funD);
Answer is A public static void main(String[] args) { List<Double> doubles = Arrays.asList (100.12, 200.32); DoubleFunction funD = d -> d + 100.0; // compile error doubles.stream ().jmsforEach(funD); // line n1 doubles.stream(). forEach(e -> System.out.println(e)); // line n2 }