Here you can find the source of subList(List> list, int page, int size)
public static List<?> subList(List<?> list, int page, int size)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { public static List<?> subList(List<?> list, int page, int size) { return list.subList(Math.min(list.size(), (page - 1) * size), Math.min(list.size(), size * page)); //below doesn't work with java 1.8_32 due to java bug. /*//from ww w .j a va 2 s .c om return list.stream() .skip((page - 1) * size) .limit(size) .collect(Collectors.toList()); */ } }