码迷,mamicode.com
首页 > 其他好文 > 详细

List<Integer> 分页

时间:2018-07-18 13:54:56      阅读:319      评论:0      收藏:0      [点我收藏+]

标签:arraylist   exce   style   nbsp   分页   class   att   opp   integer   

 
  public static void main(String [] args){
        try {
            List<Integer> skuIdList=new ArrayList<>();
            skuIdList.add(1);
            skuIdList.add(2);
            skuIdList.add(3);
            skuIdList.add(4);
            skuIdList.add(5);

            List<List<Integer>> choppedList = chopped(skuIdList, 2);

            for(List<Integer> skuList_page:choppedList){
                int c=3;
            }
            int a=2;

        }catch (Exception ex){
            int d=3;
        }
    }

    public static <T> List<List<T>> chopped(List<T> list, final int L) {
        List<List<T>> parts = new ArrayList<List<T>>();
        final int N = list.size();
        for (int i = 0; i < N; i += L) {
            parts.add(new ArrayList<T>(list.subList(i, Math.min(N, i + L))));
        }
        return parts;
    }

 

技术分享图片
 

 

技术分享图片
 

List<Integer> 分页

标签:arraylist   exce   style   nbsp   分页   class   att   opp   integer   

原文地址:https://www.cnblogs.com/caohuimingfa/p/9328142.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!