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;
}
}