// Summing the sliding windows with gatherers var strings = List.of(1, 2, 3, 4, 5, 6, 7, 8, 9); Gatherer> createSlidingWindows = Gatherers.windowSliding(2); Gatherer, ?, Integer> sumEachWindow = Gatherer.of((_, list, downstream) -> downstream.push(list.stream().mapToInt(n -> n).sum())); var result = strings.stream() .gather(createSlidingWindows) .gather(sumEachWindow) .toList(); System.out.println("result = " + result);