当前位置:网站首页>List集合实现分页
List集合实现分页
2022-06-29 06:37:00 【7258281014】
List集合实现分页
public class ListPage {
public static void main(String[] args) {
List<String> list = new ArrayList<>();
list.add("java");
list.add("python");
list.add("go");
list.add("C");
list.add("C++");
list.add("VUE");
int page = 2;
int size = 3;
list.forEach(
a -> System.out.print(a + "\t")
);
System.out.println();
List<String> pageList = handlePageList(list, page, size);
pageList.forEach(
b -> System.out.print(b + "\t")
);
}
private static List<String> handlePageList(List<String> list, Integer currentPage, Integer pageSize) {
List<String> currentPageList = new ArrayList<>();
if (list != null && list.size() > 0) {
int currIdx = (currentPage > 1 ? (currentPage - 1) * pageSize : 0);
for (int i = 0; i < pageSize && i < list.size() - currIdx; i++) {
String wordFrequencyDTO = list.get(currIdx + i);
currentPageList.add(wordFrequencyDTO);
}
}
return currentPageList;
}
}
文章仅供学习交流,侵权联系删除。
边栏推荐
- Share 10 interview questions related to JS promise
- 2022.02.14 - 239. A single element in an ordered array
- Agile invincible event
- Yyds dry goods inventory meituan's two-sided experience, and finally there was a surprise?
- Aging design guide for applets
- 解析学习幼儿机器人教育的浪潮
- Overlay histogram with density curve
- Why is there a packaging type?
- Fault: KDC warning log for id29
- Why are keys unordered in golang map
猜你喜欢

The annual technology inventory of cloud primitives was released, and it was the right time to ride the wind and waves

Share 10 interview questions related to JS promise

关于 localStorage 的一些高阶用法

Delete tag

Introduction to Ceres Quartet

RedisTemplate处理hash整数类型的问题解析

Annual inventory review of Alibaba cloud's observable practices in 2021

Failure: unable to log in to "taxpayer equity platform"

What is the "danksharding" of V God Kop on Valentine's day?

百度小程序自动提交搜索
随机推荐
Ribbon 服务调用与负载均衡
二叉树的迭代法前序遍历的两种方法
分享 10 个 JS Promise 相关的面试题
力扣今日题-324. 摆动排序 II
QT (x): control operation
Browser local storage
Rearrangement string of leetcode simple question
Leetcode simple question: judging the color of a grid on a chess board
Venn diagram proportional and color shading with semi transparency
What should I learn before learning programming?
融入STEAM教育的劳动技能课程
[deep learning] - maze task learning I (to realize the random movement of agents)
Presto-Trial
AIRNET notes 1
The echares map is implemented separately by provinces, and the tooltip user-defined prompt box, scattered annotation and scattered illumination are explained in detail
I would like to ask what securities dealers recommend? Is it safe to open an account online?
json tobean
Is there any difference between a=a+b and a+=b?
Convert data frame with date column to timeseries
Leetcode simple problem building arrays with stack operation