list集合分页list分页
程序员文章站
2022-06-21 16:34:14
...
public static List<VresourcePolice> getPaginationListVresourcePolice(List<VresourcePolice> list,int start,int end){
List<VresourcePolice> resultList =new ArrayList<>();
for(int i=1;i<=list.size();i++){
if (i>=start && i<=end) {
resultList.add(list.get(i-1));
}
}
return resultList;
}
//不严谨但是能用:
int pageNum = sceneSimpleCountParam.getPageNum();
int pageSize = sceneSimpleCountParam.getPageSize();
int startIndex = (pageNum-1)*pageSize;
int endIndex = pageNum*pageSize;
int total = orderList.size();
if (pageNum*pageSize <= total) {
orderList = orderList.subList(startIndex,endIndex);
}else{
orderList = orderList.subList(startIndex,total);
}
上一篇: sed 使用