Code: Select all
Identify the correct statements about the following code -
IntStream is1 = IntStream.of(1, 3, 5); //1
OptionalDouble x = is1.filter(i->i%2 == 0).average(); //2
System.out.println(x); //3
IntStream is2 = IntStream.of(2, 4, 6); //4
int y = is2.filter( i->i%2 != 0 ).sum(); //5
System.out.println(y); //6
Code: Select all
Compilation failure only at //4
Compilation failure at //2 and //4
I think line 2 and 5 are the difficult spots, not line 1 and 4 where "only" a IntStream is defined.