Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply 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 ...
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Errata: OCP Oracle Certified Professional Java SE 8 Programmer II - Chapter 7 page 373  RSS feed

Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First sentence on page 373 says that "This code consistently outputs the first value in the serial stream, 1." where the code, the author is referring to is How is it possible for findAny to return predictable results?

on the same page too i.e. 373 the same mistake was made:

The result is that the output could be 4, 1, or really any value in the stream. You can see that with parallel streams, the results of findAny() are no longer predictable.

Somehow it feels like author is talking about findFirst();
author & internet detective
Posts: 38911
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's correct in the book. That section is explaining that findAny() is not guaranteed to return a certain element on a parallel stream. It just happens to on a serial stream.

Whereas findFirst() loses some of the benefit of parallelism because it forces the stream to be ordered.

Does that make sense now?
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!