List<Integer> list = new ArrayList<Integer>();
for(int i = 0; i < 253; i++){
list.add(i);
}
int size = 251;
int batchNum = 50;
int count = size % batchNum > 0 ? size / batchNum + 1 : size / batchNum;
int fromIndex = 0;
int toIndex = 0;
System.out.println("count: " + count);
for(int i = 0; i < count; i++){
fromIndex = i * batchNum;
if(i == count - 1 && (size % batchNum != 0)){
batchNum = size % batchNum;
toIndex = size;
}else{
toIndex = (i + 1) * batchNum ;
}
System.out.println("fromIndex: " + fromIndex + " toIndex: " + toIndex + " batchNum: " + batchNum +" i: " + (i+1));
System.out.println(list.subList(fromIndex, toIndex));
}