List<String> objectList = Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "10");
int splitSize = 5;
int maxSize = (objectList.size() + splitSize - 1) / splitSize;
List<List<String>> flexValueLists = Stream.iterate(0, n -> n + 1)
.limit(maxSize)
.map(a -> objectList.stream().skip(a * splitSize).limit(splitSize).collect(Collectors.toList()))
.collect(Collectors.toList());
System.out.println(flexValueLists);
JAVA 将List分批
最新推荐文章于 2024-07-17 04:44:13 发布