package util;
import java.util.List;
public class PageManager
{
private List allRecords = null;//collection储存同一类型的对象的集合
private int currentPage = 0;//当前页码
private int totalPage = 0;//总页数
private int recordPerPage = -1;//每页的对象数
private int totalCount=0;//总的对象数
//初始化
public PageManager(List allRecords, int recordPerPage)
{
if (allRecords == null || recordPerPage < 1) return;
this.allRecords = allRecords;
this.recordPerPage = recordPerPage;
this.totalCount=allRecords.size();
if (allRecords.size() % recordPerPage == 0)
&nb

PageManager类用于实现Java中的简单翻页功能,通过维护所有记录的List集合、每页记录数、当前页数和总页数等属性,提供获取指定页、上下页、首尾页的方法。类构造器初始化数据,确保正确计算总页数。
最低0.47元/天 解锁文章
1743





