5. Java 8: Parallel Stream Flashcards

1
Q

Given a Collection how can one make a parallel stream?

A

Collection.parallelStream();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Given a Stream how can one transform it into a parallel stream and back to a regular stream again.

A

stream.parallel()

.sequential();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How can you use the reduce function of a Stream to sum all the integers of this Integer stream?

A

Stream stream = Stream.of(1, 2, 3);

Integer sum = stream.reduce(0, Integer::sum);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly