class="java" name="code"> import java.util.ArrayList; import java.util.List; /** * * * @author <a href="mailto:brofe@163.com">潘宁波</a> * @date Nov 6, 2014 3:36:26 PM */ 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; } System.out.println("》》》》》》》》》》 第【" + pageNo + "】页"); for (Integer i : list.subList(fromIndex, toIndex)) { System.out.println(i); } } } }