• 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

Chap 4, #15 (Review Question IZO-809) - Sybex

 
Greenhorn
Posts: 11
2
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
List compiles for me, and D is what I would expect, but the answer says E works as well, but Set doesn't compile for me... what am I missing?

Doesn't compile...

Map<Boolean, Set<String>> ml =
Stream.of("I", "Love", "CodeRanch")
     .collect(Collectors.partitioningBy(so -> so.length() > 3));

This compiles fine...

Map<Boolean, List<String>> ml =
Stream.of("I", "Love", "CodeRanch")
     .collect(Collectors.partitioningBy(so -> so.length() > 3));

Thanks!
 
author & internet detective
Posts: 41860
908
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
Bradley,
Good question. If you read the review question *really* carefully, it says when specific parameters are passed to partitioning by. This does compile so E is in fact correct:



ps - have a cow for supplying code to explain your question (rather than just saying "I don't get why E is true")
 
Arthur, where are your pants? Check under this tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic