Here you can find the source of subList(List
public static <T> List<T> subList(List<T> list, int start, int end)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static <T> List<T> subList(List<T> list, int start, int end) { List<T> subList = new ArrayList<>(); for (int i = start; i < end; i++) { if (list.size() > i) { subList.add(list.get(i)); } else { break; }/*from w w w.j a v a 2 s .c o m*/ } return subList; } }