hello_dakewang

导航

Java中常见的分页算法

在查询数据的时候或者展示数据的时候经常会使用分页,介绍几种简单的分页算法:

    //总的页数

    int total = 30;

    //每页个数

    int pageSize = 6;

 

  1.one 

      int pageSum =  (total-1)/pageSize + 1;

  2.two

    int pageSum = total%pageSize == 0 ? total / pageSize : total / pageSize 1;

  3.three

    int pageSum = (total+pageSize-1)/pageSize;

posted on 2018-03-24 16:07  hello_dakewang  阅读(750)  评论(0编辑  收藏  举报