• 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: 51
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
Marshal
Posts: 37898
595
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: 51
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
Marshal
Posts: 37898
595
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!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!