Page 1 of 1

[HD-OCP17/21-Fundamentals Pg 0, Sec. 21.1.6 - quiz]

Posted: Thu Feb 27, 2025 6:30 pm
by joaoclopes
Hello,

On Q2, 2.
Since the limitmethod limits the incoming streams to at mostthe given number of elements and since the stream in this example contains only five elements, limit(10)will pass on all the five elements to the outgoing stream. However, one of the elements is greater than 70and so, noneMatch(i -> i>70);will return false.
In reality the limit(10) will pass only the first 4 elements to the stream right? Because the when it reaches the element "80" the noneMatch will return false.

Thanks,
João

Re: [HD-OCP17/21-Fundamentals Pg 0, Sec. 21.1.6 - quiz]

Posted: Thu Feb 27, 2025 10:49 pm
by admin
That's right. From the perspective of the limit(10) method, it will not pass more than 10 elements to the next operation but since the noneMatch operation fails at the fourth element itself, only 4 elements will actually get passed. The explanation should make this point clear.

thank you for your feedback!

Re: [HD-OCP17/21-Fundamentals Pg 0, Sec. 21.1.6 - quiz]

Posted: Sat Mar 01, 2025 9:07 am
by joaoclopes
No problem! Glad that I could help.