Here you can find the source of sliceList(final List
public static final List<Long> sliceList(final List<Long> list, final long offset, final int limit) throws IllegalArgumentException
//package com.java2s; //License from project: Open Source License import java.util.List; import java.util.ArrayList; public class Main { public static final List<Long> sliceList(final List<Long> list, final long offset, final int limit) throws IllegalArgumentException { checkList(list, Integer.MAX_VALUE); int len = list.size(); if (offset > len) { return new ArrayList<Long>(0); }/*from w w w. j a v a2 s . c o m*/ return list.subList((int) offset, min((int) (offset + limit), len)); } public static final void checkList(List list, int limit) { if (list == null) { throw new IllegalArgumentException("Null list"); } int len = list.size(); if (len == 0) { throw new IllegalArgumentException("Empty list (size=0)"); } if (len > limit) { throw new IllegalArgumentException("List too large " + len + "; greater than limit: " + limit); } } public static final int min(final int i, final int j) { if (j > i) { return i; } return j; } }