CH10 - Streams Flashcards

(7 cards)

1
Q

Stream

A

A stream in Java is a sequence of data.

A stream pipeline consists of the operations that run on a stream to produce a result.

With streams, the data isn’t generated up front - it is created when needed.

This is an example of lazy evaluation, which delays execution until necessary.

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

Source

A

Where the stream comes from

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

Intermediate operations

A

Transforms the stream into another one.
There can be as few or as many intermediate operations

Since streams use lazy evaluation, the intermediate oeprations do not run until the terminal operation runs.

Required part - No
Exist multiple time - Yes
Return stream type - Yes
Executed upon method call - No
Stream valid after call - Yes

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

Terminal operation

A

Produces result.
Streams are not valid after terminal operation completes.

Required part - Yes
Exist multiple time - No
Return stream type - No
Executed upon method call - Yes
Stream valid after call - No

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

Stream.iterate(seed, unaryOperator)

A

Creates Stream by using seed for first element and then calling UnartOperator for each subsequent element upon request

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

Stream.iterate(seed, predicate, unaryOperator)

A

Creates Stream by using seed for first element and then calling UnaryOperator for each subsequent element upon request. Stops if Predicate returns false.

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