Which of the following is true?
4: Stream<Integer> s = Stream.of(1); 5: IntStream is = s.mapToInt(x -> x); 6: DoubleStream ds = s.mapToDouble(x -> x); 7: Stream<Integer> s2 = ds.mapToInt(x -> x); 8: s2.forEach(System.out::print);
D.
Line 4 should obviously look OK.
It creates a Stream and uses autoboxing to put the Integer 1 inside.
Line 5 converts to a primitive, again using autoboxing.
Line 6 converts to a double primitive, which works since double d = 1; would work.
Line 7 is where it all falls apart.
Converting from a double to an int would require a cast inside the lambda.