Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Stefan Wendelmann
Added: May 22, 2019 7:19 AM
Modified: May 22, 2019 7:32 AM
Views: 8
  1. // https://e.printstacktrace.blog/divide-a-list-to-lists-of-n-size-in-Java-8/
  2. final List<Integer> numbers = Arrays.asList(1,2,3,4,5,6,7);
  3. final int chunkSize = 3;
  4. //Google
  5. Lists.partition(new ArrayList<>(numbers), chunkSize);
  6. //Apache Commons
  7. ListUtils.partition(new ArrayList<>(numbers), chunkSize);