/**
* @createTime 2019年7月15日上午10:48:17
* @description 手动分页
*/
public static <T> List<T> manualPaging(List<T> list,int page,int sizeEach){
List<T> listTemp = new ArrayList<T>();
int size = list.size();
if (size < 1) {
return listTemp;
}
int listSize = list.size();
int startIndex = (page - 1) * sizeEach;// 起点索引
int endIndex = page * sizeEach - 1;// 终点索引
int maxIndex = listSize - 1;// 集合容量的最大索引
// if (maxIndex < startIndex) {
// return listTemp;
// } else
if (startIndex <= maxIndex && maxIndex < endIndex) {
for (int i = startIndex; i <= maxIndex; i++) {
listTemp.add(list.get(i));
}
} else if (endIndex <= maxIndex) {
for (int i = startIndex; i <= endIndex; i++) {
listTemp.add(list.get(i));
}
}
return listTemp;
}