JAVA实现分页

for(int i = 0 ;i < 2000;i++){
    ids.add(i);
}
List result = new ArrayList<>();
Map map = new HashMap<>();
for(int limit = 500,skip = 0 ;skip < ids.size();skip = skip+ limit){
    List idList = ids.stream().skip(skip).limit(limit).collect(Collectors.toList());
    result.addAll(idList);
}

你可能感兴趣的:(JAVA实现分页)