list集合分页
public class ListPaging { /** * * @param dataList 数据源对象集合 * @param pageSize 每页条数 * @param currentPage 当前为第几页 * @param <F> * @return */ public static <F> List<F> datepaging(List<F> dataList, int pageSize, int currentPage) { List<F> list = new ArrayList<>(); if (dataList != null && dataList.size() > 0) { // currIdx -->下一页的索引起始位 int currIdx = (currentPage > 1 ? (currentPage - 1) * pageSize : 0); for (int i = 0; i < pageSize && i < dataList.size() - currIdx; i++) { F f = dataList.get(currIdx + i); list.add(f); } } return list; } public static void main(String[] args) { } }