import java.util.ArrayList;
import java.util.List;
public class ListPagingTest {
public static void main(String[] args) {
List<Integer> list = new ArrayList<Integer>();
for (Integer i = 0; i < 1000; i++) {
list.add(i);
}
int pageNumber = 50; // 每页记录数
int totalCount = list.size(); // 总记录数
int totalPage = totalCount / pageNumber; // 总页数
if((totalCount % pageNumber) > 0){
totalPage += 1;
}
for (int pageNo = 0; pageNo < totalPage; pageNo++) {
int fromIndex = pageNo * pageNumber;
int toIndex = ((pageNo + 1) * pageNumber);
if(toIndex > totalCount){
toIndex = totalCount;
}
for (Integer i : list.subList(fromIndex, toIndex)) {
System.out.println(i);
}
}
}
}
import java.util.List;
public class ListPagingTest {
public static void main(String[] args) {
List<Integer> list = new ArrayList<Integer>();
for (Integer i = 0; i < 1000; i++) {
list.add(i);
}
int pageNumber = 50; // 每页记录数
int totalCount = list.size(); // 总记录数
int totalPage = totalCount / pageNumber; // 总页数
if((totalCount % pageNumber) > 0){
totalPage += 1;
}
for (int pageNo = 0; pageNo < totalPage; pageNo++) {
int fromIndex = pageNo * pageNumber;
int toIndex = ((pageNo + 1) * pageNumber);
if(toIndex > totalCount){
toIndex = totalCount;
}
for (Integer i : list.subList(fromIndex, toIndex)) {
System.out.println(i);
}
}
}
}