Question: Answer the following questions with regard to the stream pipeline in Fig. 17.7: a) How many times does the filter operation call its lambda argument?
Answer the following questions with regard to the stream pipeline in Fig. 17.7:
a) How many times does the filter operation call its lambda argument?
b) How many times does the map operation call its lambda argument?
c) If you reverse the filter and map operations in the stream pipeline, how many times does the map operation call its lambda argument?
Fig. 17.7

1 // Fig. 17.7: StreamFilterMapReduce.java 2 // Triple the even ints from 2 through 10 then sum them with IntStream. import java.util.stream. IntStream; 3 4 5 6 public class StreamFilterMapReduce { public static void main(String[]args) { // sum the triples of the even integers from 2 through 10 System.out.printf( "Sum of the triples of the even ints from 2 through 10 is: %d%n", IntStream.rangeClosed (1, 10) .filter (x -> x % 2 == 0) .map(x -> x * 3) .sum()); 9 10 [] 12 13 14 15 } } Sum of the triples of the even ints from 2 through 10 is: 90
Step by Step Solution
3.46 Rating (159 Votes )
There are 3 Steps involved in it
Based on the description of the image which contains a Java code snippet for a str... View full answer
Get step-by-step solutions from verified subject matter experts
