mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix code
This commit is contained in:
parent
59d264048f
commit
a0ac4362dd
@ -844,11 +844,12 @@ public class CollUtil {
|
||||
return result;
|
||||
}
|
||||
|
||||
ArrayList<T> subList = new ArrayList<>(size);
|
||||
final int initSize = Math.min(collection.size(), size);
|
||||
ArrayList<T> subList = new ArrayList<>(initSize);
|
||||
for (final T t : collection) {
|
||||
if (subList.size() >= size) {
|
||||
result.add(subList);
|
||||
subList = new ArrayList<>(size);
|
||||
subList = new ArrayList<>(initSize);
|
||||
}
|
||||
subList.add(t);
|
||||
}
|
||||
|
@ -304,6 +304,14 @@ public class CollUtilTest {
|
||||
Assert.assertEquals(3, split.get(0).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void splitTest2() {
|
||||
final ArrayList<Integer> list = ListUtil.of(1, 2, 3, 4, 5, 6, 7, 8, 9);
|
||||
final List<List<Integer>> split = CollUtil.split(list, Integer.MAX_VALUE);
|
||||
Assert.assertEquals(1, split.size());
|
||||
Assert.assertEquals(9, split.get(0).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void foreachTest() {
|
||||
final HashMap<String, String> map = MapUtil.newHashMap();
|
||||
|
Loading…
x
Reference in New Issue
Block a user