Java List Sub List getSubList(List list, int start, int limit)

Here you can find the source of getSubList(List list, int start, int limit)

Description

get Sub List

License

Apache License

Declaration

public static <T> List<T> getSubList(List<T> list, int start, int limit) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;
import java.util.List;

public class Main {

    public static <T> List<T> getSubList(List<T> list, int start, int limit) {

        if (list == null || list.isEmpty()) {
            return new ArrayList<T>(0);
        }/*w ww. j  ava 2 s  .c o  m*/

        int listLength = list.size();
        if (start > listLength - 1) {
            return new ArrayList<T>();
        }

        limit = start + limit > listLength ? listLength - start : limit;
        return list.subList(start, start + limit);
    }
}

Related

  1. getSubList(List source, int nFrom, int nTo)
  2. getSubList(List allKeys, String part)
  3. getSubList(List list, int from, int maxnum)
  4. getSublist(List list, int i)
  5. getSubList(List list, int start, int end)
  6. getSubListFromStart(List list, int length)
  7. getSubListIndex(Object[] tofind, Object[] tokens)
  8. isSubList(List l1, List l)
  9. lastIndexOfSubList(final List list0, final List list1)