Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

1Z0-809-Sybex 2015 by Scott Selikoff and Jeanne Boyarsky, chapter 4, printing a stream

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hullo!


In the table 4.5 given at page 204 it says that the following line of code is not destructive to the Stream. But I think it is because of the terminal operation count():



I ran this code and it gives an IllegalStateException. I also checked the errata for the book and this is not listed there.
 
Marshal
Posts: 25594
69
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi Mihai, welcome to the Ranch!

Could you post all of the code that you ran? Jeanne will have the book of course, but others don't.
 
Marshal
Posts: 69494
277
  • Likes 1
  • Mark post as helpful
  • send pies
  • Report post to moderator
Welcome to the Ranch (again)

There is something familiar about that code; please have a look at these old links: 1 2 3 4 5. Those links may answer the same question.

A post in link 1 wrote:As Campbell alluded to, this has been discussed before. I don't believe it is an error because the intent is that peek() is not destructive. That said, enough people found this unclear that we rewrote the passage in our 816 book. We didn't change it to "yes". We updated to avoid the ambiguity. (Yes would be incorrect because it is count() that is destructive, not peek()).

 
Mihai Apostol
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Report post to moderator
Oh, now I see, thanks for the link! I guess I should've searched the forum first before posting. I will delete the post tonight.

 
Campbell Ritchie
Marshal
Posts: 69494
277
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please don't try deleting posts; we believe any ost might be useful in future.
 
Do not meddle in the affairs of dragons - for you are crunchy and good with ketchup. Crunchy tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic