Last active
December 18, 2015 15:09
-
-
Save codeaholicguy/5f3db089e225f7be6d5c to your computer and use it in GitHub Desktop.
This file contains 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
List<Integer> list1 = Arrays.asList(1, 2, 3, 4, 5, 6, 7); | |
List<Integer> list2 = Arrays.asList(2, 4, 6); | |
List<Integer> list3 = Arrays.asList(3, 5, 7); | |
List<List<Integer>> list = Arrays.asList(list1, list2, list3); | |
// Output [[1, 2, 3, 4, 5, 6, 7], [2, 4, 6], [3, 5, 7]] | |
System.out.println(list); | |
Function<List<Integer>, Stream<Integer>> flatMapper = l -> l.stream(); | |
// Output 1 2 3 4 5 6 7 2 4 6 3 5 7 | |
list.stream().flatMap(flatMapper).forEach(System.out::println); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment