import java.util.List; public class ListUtils { /** * 取list中某一段连续元素 * * @param list * @param beginIndex * @param endIndex * @return */ public static <T> List<T> fetchElementFromList(List<T> list, int beginIndex, int endIndex) { List<T> result = null; if (null != list && !list.isEmpty()) { int size = list.size(); int fromIndex = beginIndex < 0 ? 0 : beginIndex; int toIndex = endIndex > size ? size : endIndex; if (fromIndex < toIndex) { result = list.subList(fromIndex, toIndex); } } return result; } }
标签:endIndex,beginIndex,int,List,元素,list,一段,size From: https://www.cnblogs.com/cool5201314/p/17506258.html