Question: Given the following code snippet, what statement about the values printed on lines p1 and p2 is correct? A. They are always the same. B.
Given the following code snippet, what statement about the values printed on lines p1 and p2 is correct?

A. They are always the same.
B. They are sometimes the same.
C. They are never the same.
D. The code does not compile.
E. The code will produce a ConcurrentModificationException at runtime.
F. None of the above.
var db = Collections.synchronized List (new ArrayList ()); IntStream.range (1,6) .parallel() .map (i > {db.add (i); return i;}) .forEachOrdered (System.out::print); // pl System.out.println(); db.forEach (System.out::print); // p2
Step by Step Solution
3.48 Rating (151 Votes )
There are 3 Steps involved in it
The code snippet youve shown is Java code and it demonstrates the use of parallel streams with a synchronized collection Lets break down the component... View full answer
Get step-by-step solutions from verified subject matter experts
