Created
December 18, 2014 06:13
-
-
Save tag1216/994043491d9708492071 to your computer and use it in GitHub Desktop.
Collectors.groupingBy()でList<? extends String>をcollect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Map<Integer, List<String>> list4 = Stream.of("a", "b") | |
.collect(Collectors.groupingBy( | |
String::length, | |
Collectors.toCollection(() -> new ArrayList<String>()) | |
)); | |
Map<Integer, List<? extends String>> list5 = Stream.of("a", "b") | |
.collect(Collectors.groupingBy( | |
String::length, | |
Collector.of( | |
() -> new ArrayList<String>(), | |
(list, x) -> list.add(x), | |
(x, y) -> { x.addAll(y); return x; }, | |
list -> (List<? extends String>) list | |
) | |
)); | |
Map<Integer, List<? extends String>> list6 = Stream.of("a", "b") | |
.collect(Collectors.groupingBy( | |
String::length, | |
Collectors.collectingAndThen( | |
Collectors.toList(), | |
l -> (List<? extends String>) l | |
) | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment