Here you can find the source of subList(List
Parameter | Description |
---|---|
input | a parameter |
startIndex | a parameter |
count | a parameter |
public static <T> List<T> subList(List<T> input, int startIndex, int count)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { /**//from w w w . ja va 2 s .co m * Calculates the substring of a list based on a 1 based start index never exceeding * the bounds of the list. * @param input * @param startIndex * @param count * @return */ public static <T> List<T> subList(List<T> input, int startIndex, int count) { int fromIndex = startIndex - 1; int toIndex = fromIndex + count; if (toIndex >= input.size()) { toIndex = input.size(); } return input.subList(fromIndex, toIndex); } }