There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:hi Ruben,
welcome to the Ranch and enjoy the stay!
A stream can be without a terminal operation. In that case the stream is not executed.
Mikalai Zaikin wrote:I would say there is a big difference between stream and stream pipeline ;)
Stream is an approach to access data stored in some backed storage (collection, file, generator)
Pipeline -- consists of a stream, zero or more intermediate operation, and exactly one terminal operation.
There are three kinds of actuaries: those who can count, and those who can't.
Mikalai Zaikin wrote:I think it's more English language area
"at most one" means "not more than one" (IMHO)
and "one" falls into this category
[OCP 21 book] | [OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Jeanne Boyarsky wrote:There is precision and there is reading into things
.
We use stream and stream pipeline interchangeably in many places in the book. We are careful where it matters. For example the stream() method is not a pipeline.
Yes, "at most one" means "not more than one". Which means "optional". The terminal option isn't required. However, the pipeline isn't useful with one because it returns a stream reference instead of executing.
[OCP 21 book] | [OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Jeanne Boyarsky wrote:No. A is still true. I think you might find it easier to understand why the opposite is false.
Inverting option A gives "A stream can have more than one terminal operations". That's clearly false. We both agree there can't be two.
Stephan van Hulst wrote:No, that is incorrect.
A stream pipeline can have zero terminal operations without problems. It just doesn't do anything.
Which are true statements about terminal operations in a stream that runs successfully?
Stephan van Hulst wrote:
I will admit I may have caused some confusion with my previous post. In that post, I said that a stream pipeline may have zero terminal operations. I made that assertion about some stream, not the specific case of "a stream that runs successfully", which was mentioned in the original problem statement. Here's a simple proof:
This piece of code creates a stream pipeline with one intermediate operation and zero terminal operations. It does not do anything useful, but the program compiles and runs just fine.
Ruben Young On wrote:
As per the JavaDocs, a stream pipeline consists of a terminal operations.
[OCP 21 book] | [OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
A tiny monkey bit me and I got tiny ads:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|