Created
July 16, 2019 05:41
-
-
Save jickoo/b2c14fcae3d298140d8d326ebf6ae710 to your computer and use it in GitHub Desktop.
java stream Collectors.partitioningBy #java #stream #partitioningBy
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
Stream<Integer> stream = Stream.of(1,2,3,4); | |
Map<Boolean, List<Integer>> patition = stream.collect(Collectors.partitioningBy(s -> (s % 2) == 0)); | |
List<Integer> oddList = patition.get(false); | |
System.out.println(oddList); | |
List<Integer> evenList = patition.get(true); | |
System.out.println(evenList); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment