• 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
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Rob Spoor
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:

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: 41763
887
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")
 
Wanna see my flashlight? How about 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