Here you can find the source of subList(List
public static <T> List<T> subList(List<T> it, int offset, int limit)
//package com.java2s; //License from project: LGPL import java.util.Collections; import java.util.List; public class Main { public static <T> List<T> subList(List<T> it, int offset, int limit) { if (it == null) { return it; }/*from w ww. j a va 2 s . c o m*/ if (it.size() <= offset) { return Collections.emptyList(); } if (limit < 0) { limit = it.size(); } if (offset < 0) { offset = 0; } limit = offset + limit > it.size() ? it.size() - offset : limit; return (limit == it.size() && offset == 0) ? it : it.subList(offset, offset + limit); } }