场景

根据指定每页显示数据行数,计算分多少页。

final int limitNum = 100;
int dataSize = 1079;

// 方法1
//Integer pageNum = dataSize / limitNum;
//if (dataSize % limitNum != 0) {
// pageNum++;
//}

// 方法2
int pageNum = (dataSize - 1) / limitNum + 1;

System.out.println(pageNum);

for (int i = 0; i < pageNum; i++) {
Integer beginRow = limitNum * i;
System.out.println("limit " + beginRow + "," + limitNum);
}