public static List subList(List allList, int fromIndex, int toIndex) {
List list = new ArrayList();
if (ListUtils.isEmpty(allList)) {
return new ArrayList();
}
for (; fromIndex < toIndex; fromIndex++) {
list.add(allList.get(fromIndex));
}
return list;
}
1 allList 里面的数据是 []
然后你在下面 获取 alllist.get(0) alllist.get(1) 等 都是null 你list.add(null) ? 肯定报错啊 ;
for循环 条件 只能是 alllist.size()啊
2 你的List 最好给个类型
不会,但list本身sublist会
把你的调用代码贴出来看看