Home » Tip Bank » Java
  • Comment on this Article
Language: Java
Expertise: Intermediate
May 1, 2020

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Watch

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();
Octavia Anghel
 
Submit a Tip
Browse "Java" Tips
Browse All Tips
w3.org
codeschool.com