Java list 分组打印1000条数据,100为一组打印
List<Integer> list1 = new ArrayList<>();
for (int i = 1; i <= 101; i++) {
list1.add(i);
}
if (list1.size() > 100) {
int i = list1.size() / 100;
for (int a = 0; a < i + 1; a++) {
if (a == 0) {
List<Integer> integers1 = list1.subList(a, 100);
System.out.println(integers1);
} else if (a > 0 && a < i) {
List<Integer> integers1 = list1.subList(a * 100, (a + 1) * 100);
System.out.println(integers1.toString().replace(" ", ""));
System.out.println(integers1);
} else {
List<Integer> integers1 = list1.subList(i * 100, list1.size());
if (integers1 != null && integers1.size() != 0){
System.out.println(integers1);
}
}
}
} else {
System.out.println(list1);
}