This week's book giveaway is in the Raspberry Pi forum.
We're giving away four copies of Getting started with Java on the Raspberry Pi and have Frank DelPorte on-line!
See this thread for details.
Win a copy of Getting started with Java on the Raspberry Pi this week in the Raspberry Pi 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

OCP 17 Study Guide Chapter 10 Exam Essentials

 
Greenhorn
Posts: 25
3
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Everyone

The textbook says:

Compare groupingBy() and partitioningBy(). The groupingBy() method is a terminal operation that creates a Map. The keys and return types are determined by the parameters you pass. The values in the Map are a Collection for all the entries that map to that key. The partitioningBy() method also returns a Map. This time, the keys are true and false. The values are again a Collection of matches. If there are no matches for that boolean, the Collection is empty.



I actually found this paragraph very misleading, at the point that I had to go back and review the topic, after many hours spent trying to get and memorize comparators.
For what I finally got, groupingBy() and partitioningBy() methods are not terminal operations and they don't return Map. They aren't Stream's methods, but they are static methods in class Collectors, that returns collector objects. The terminal operation in this case is collect().
 
Master Rancher
Posts: 4616
61
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup, that's exactly right.  Typically, people create the groupingBy() collector in the same line as the collect() method call, so it's tempting to think of them as all happening together in the same step.  But when you look more closely, you're quite correct that the groupingBy is not terminal, and not even a stream operation... but the collect() is what actually terminates the stream.
 
author & internet detective
Posts: 41763
885
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've added this to errata and credited you. Thanks for noticing!
 
Put the moon back where you found it! We need it for tides and poetry and stuff. Like this tiny ad:
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
    Bookmark Topic Watch Topic
  • New Topic