, List s:
List<List<Integer>> slices = Stream.of(source).flatMap(l->
IntStream.range(0, l.size()).mapToObj(i->new int[]{i, l.get(i)})
).collect(collectingAndThen(
groupingBy(a->a[0], TreeMap::new, mapping(a->a[1], toList())),
m->new ArrayList<>(m.values()))
);
, :
int maxSize=IntStream.range(0,source.length).map(i->source[i].size()).max().orElse(0);
List<List<Integer>> slices = Stream.of(source).flatMap(l->
Stream.concat(
IntStream.range(0, l.size()).mapToObj(i->new int[]{i, l.get(i)}),
IntStream.range(l.size(), maxSize).mapToObj(i->new int[]{i, 0})
)
).collect(collectingAndThen(
groupingBy(a->a[0], TreeMap::new, mapping(a->a[1], toList())),
m->new ArrayList<>(m.values()))
);
, import static java.util.stream.Collectors.*;, .