• Post Reply Bookmark Topic Watch Topic
  • New Topic

OCP Java 8 SE Study Guide - Chapter 4-Printing a Stream - Sybex  RSS feed

 
Ranch Hand
Posts: 46
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The table 4.5 has typo. In third row , column Destructive to Stream? value should be Yes. But it is No.
count method is terminal operation, which mean stream object can not be used after this call.
 
author & internet detective
Sheriff
Posts: 37820
582
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prateek,
That's not a typo. The intent of that column "destructive to stream?" is whether the printing is destructive. The peek() call is not destructive to the stream, so the column has a no.

I agree that count() is destructive. A terminal operation has to run for a pipeline to have meaning and the peek to happen.
 
prateek shaw
Ranch Hand
Posts: 46
1
Java Oracle
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok Thanks.

It is for peek not for count.

Thanks.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37820
582
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

prateek shaw wrote:It is for peek not for count.


Exactly!
 
Beware the other head of science - it bites! Nibble on this message:
ScroogeXHTML 7.1 - RTF to HTML5 / XHTML converter
https://coderanch.com/t/690611/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!