This commit is contained in:
Looly 2023-09-15 12:31:20 +08:00
parent 9a088883a1
commit 64d4d64ccc
2 changed files with 20 additions and 1 deletions

View File

@ -593,7 +593,7 @@ public class ListUtil {
* @return 分段列表
* @since 5.4.5
*/
public static <T> List<List<T>> partition(final List<T> list, final int size) {
public static <T> List<List<T>> partition(final List<T> list, final int size) {
if (CollUtil.isEmpty(list)) {
return empty();
}

View File

@ -0,0 +1,19 @@
package org.dromara.hutool.core.collection;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
public class Issue3308Test {
@Test
void partitionTest() {
final List<String> list = new ArrayList<>();
for (int i = 0; i < 100000; i++) {
list.add("Str"+i);
}
final List<List<String>> partition = ListUtil.partition(list, 1000);
Assertions.assertEquals(100, partition.size());
}
}