Here you can find the source of getRange(List
Parameter | Description |
---|---|
list | the List |
start | the start index |
T | the list type |
public static <T> List<T> getRange(List<T> list, int start)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { /**// ww w . ja va 2s. c om * Gets all elements from a list starting from the given index. * * @param list the List * @param start the start index * @param <T> the list type * @return the sublist of all elements from index {@code start} and on; empty list * if the start index exceeds the list's size */ public static <T> List<T> getRange(List<T> list, int start) { if (start >= list.size()) { return new ArrayList<>(); } return list.subList(start, list.size()); } }