• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Errata for OCP: Oracle Certified Professional Java SE 8 Programmer II Study Guide - Chapter 7

 
Greenhorn
Posts: 15
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

In chapter 7, "Creating parallel streams":

On the other hand, flatMap() creates a new stream that is not parallel by default, regardless of whether the underlying elements were parallel.



Also in chapter 7, question 13 the explanation says:

flatMap() is a new stream that is not parallel by default, even though its elements are parallel streams.



But the truth is that flatMap preserves the parallel attribute of the stream going in.



It's the Stream builder the one who sets the parallel attribute to false in the new Stream.

 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mike,

Yes, if the stream being mapped to is parallel, it will preserve that parallel mapping. The text was referring to the underlying streams. For example, the following is not a parallel stream even though cats and bears are both parallel.

You can contrast that with this behavior which confirms the underlying elements are still parallel:

The idea in the text is to say that taking multiple parallel streams and applying a flatMap() operation does not preserve the parallel attribute on the underlying streams. As you pointed out, it does preserve it on the top-most Stream.of(...).parallel(). We'll add a note to be clearer about this in the text next time!
 
reply
    Bookmark Topic Watch Topic
  • New Topic