Java tutorial
//package com.java2s; import java.util.List; public class Main { public static <T> List<T> limit(List<T> list, Integer start, Integer numberOfRecords) { if (start != null && numberOfRecords != null && start >= 0 && numberOfRecords >= 0) { int indexFrom = start; int indexTo = start + numberOfRecords; if (indexFrom > list.size()) { indexFrom = list.size(); } if (indexTo > list.size()) { indexTo = list.size(); } return list.subList(indexFrom, indexTo); } else { return list; } } }