1.
List newTargetList = new ArrayList<>();
List targetList = new ArrayList<>();
for (int i = 0; i < targetList.size(); i++) {
newTargetList.add(targetList.get(i));
if(i > 0 && (i+1) % 100 == 0) { // 100개일경우 i = 99일떄 (99 + 1) 100이므로 true
semplefunction(newTargetList);
newTargetList.clear();
} else if(i == targetList.size()-1) { // 100개이하일때
semplefunction(newTargetList);
}
}
2.
List dividedList = new ArrayList<>(); // 100개씩 나눠진 List데이터 리스트
List remainderList = new ArrayList<>(); // 100개로 나눴을때 나머지 리스트
list targetList = new ArrayList<>();
for (int i = 0; i < targetList.size(); i++) { // 0 ~ 399 < 400
if(i!= 0 && i % 100 == 0) {
dividedList.add(remainderList);
sempleFunction(dividedList);
remainderList.clear();
}
remainderList.add(targetList.get(i));
}
if(remainderList.size() > 0) {
sempleFunction(remainderList);
}
'자바' 카테고리의 다른 글
[오류]Could not target platform: 'Java SE 11' using tool chain: 'JDK 8 (1.8)' in eclipse (0) | 2022.11.08 |
---|---|
[TIFF FILE TO PDF] tiff 파일을 pdf로 변환 (1) | 2022.11.02 |
[ENUM] enum이란.. (0) | 2022.10.26 |
[Equals VS contentEquals] (0) | 2022.10.25 |
[정규식] 자바에서 숫자를 체크하는 정규식 (1) | 2022.10.25 |