@Test public void testPartition() { List<Integer> list = new ArrayList<>(); for (int i = 0; i < 99; i++) { list.add(i); } List<List<Integer>> partitions = Lists.partition(list, 5); assertEquals(20, partitions.size()); int count = 0; for (int i = 0; i < 19; i++) { List<Integer> partition = partitions.get(i); assertEquals(5, partition.size()); for (int j : partition) { assertEquals(count, j); count += 1; } } assertEquals(4, partitions.get(19).size()); for (int i = 0; i < 4; i++) { assertEquals(95 + i, partitions.get(19).get(i).intValue()); } }
static <T> List<List<T>> partition(List<T> list, int size) { return new Partition<>(list, size); }
Lists { static <T> List<List<T>> partition(List<T> list, int size) { return new Partition<>(list, size); } }
Lists { static <T> List<List<T>> partition(List<T> list, int size) { return new Partition<>(list, size); }  }
Lists { static <T> List<List<T>> partition(List<T> list, int size) { return new Partition<>(list, size); }   }
Lists { static <T> List<List<T>> partition(List<T> list, int size) { return new Partition<>(list, size); }    }