partioning operation java

Solutions on MaxInterview for partioning operation java by the best coders in the world

showing results for - "partioning operation java"
Neele
11 May 2016
1@Test
2public void givenList_whenParitioningIntoSublistsUsingPartitionBy_thenCorrect() {
3    List<Integer> intList = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8);
4
5    Map<Boolean, List<Integer>> groups = 
6      intList.stream().collect(Collectors.partitioningBy(s -> s > 6));
7    List<List<Integer>> subSets = new ArrayList<List<Integer>>(groups.values());
8
9    List<Integer> lastPartition = subSets.get(1);
10    List<Integer> expectedLastPartition = Lists.<Integer> newArrayList(7, 8);
11    assertThat(subSets.size(), equalTo(2));
12    assertThat(lastPartition, equalTo(expectedLastPartition));
13}
similar questions
queries leading to this page
partioning operation java