Is it possible to partition a List in pure Jdk8 into equal chunks (sublists).
I know it is possible using Guava Lists class, but can we do it with pure Jdk? I don\'t wan
Try using this code, it uses Java 8:
public static Collection> splitListBySize(List intList, int size) {
if (!intList.isEmpty() && size > 0) {
final AtomicInteger counter = new AtomicInteger(0);
return intList.stream().collect(Collectors.groupingBy(it -> counter.getAndIncrement() / size)).values();
}
return null;
}