dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Intermediate
May 1, 2020

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
 
Thanks for your registration, follow us on our social networks to keep up-to-date