Skip to content

Instantly share code, notes, and snippets.

@jickoo
Created July 16, 2019 05:41
Show Gist options
  • Save jickoo/b2c14fcae3d298140d8d326ebf6ae710 to your computer and use it in GitHub Desktop.
Save jickoo/b2c14fcae3d298140d8d326ebf6ae710 to your computer and use it in GitHub Desktop.
java stream Collectors.partitioningBy #java #stream #partitioningBy
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