dcsimg
 

Submitted by: Octavia Anghel(octaviaanghel@gmail.com)

Friday May 1st 2020 by Octavia Anghel

Language: Java, Expertise: Intermediate: This code example shows you how to chunk a list in functional style.

The following code chunks a List in functional style:

AtomicInteger counter = new AtomicInteger();
Collection result = list.stream()
        .collect(Collectors.groupingBy(c - counter.getAndIncrement() / chunkSize))
        .values();
Home
Mobile Site | Full Site