1,引入依赖
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>
2,代码示例
List<String> strings = new ArrayList<>();
for (int i = 0; i < 11; i++) {
strings.add(String.valueOf(i));
}
List<List<String>> partition = ListUtils.partition(strings, 2);
System.out.println(partition);