Given the code fragment:
List
List
//line n1
Which code fragment, when inserted at line n1, prints 10 20 15 30?
Given the code fragment:
List
List
//line n1
Which code fragment, when inserted at line n1, prints 10 20 15 30?
Stream.of(list1, list2) creates a Stream of the two lists. flatMap(list -> list.stream()) flattens this Stream of lists into a single Stream containing the elements of both lists. forEach(s -> System.out.print(s +
Sorry Answer is A. Tested
the answer is A
A tested
Answer is A. Tested
A is the correct answer
Answer is A
Not tested, but I think : - B doesn't compile because List.intStream() doesn't exist - C doesn't compile because Stream.flatMap() expects a function as parameter, while a Stream is provided - D almost compiles but doesn't : flatMapToInt() exists, though a wrong parameter is provided. Expected: Function<List<Integer>, IntStream> Provided: Function<List<Integer>, Stream<Integer>>
Answer is A.
Answer is B. Tested.