java分页

public static void main(String[] args) {
        int total = 0;    //总数
        int pageSize = 3;   //每页条数
        int pageNo = total / pageSize;  //页数
        if(total % pageSize != 0){
            pageNo ++;
        }
        for(int i = 1; i <= pageNo; i++){
            int num = 0;    //起始标记
            int size = i * pageSize;   //结束标记
            if(size > total){
                size = total;
            }
            int startNum = size;    //起始
            int endNum = (i - 1) * pageSize;   //结束
            System.out.println("===" + size + "===");
            for(int j = 0; j < (startNum - endNum); j++){
                num ++;
                System.out.println("第" + i + "页,第" + num + "条");
            }
            if(size == num){
                continue;
            }
        }
    }

  

posted @ 2020-04-21 18:10  面向bug编程  阅读(240)  评论(0编辑  收藏  举报