当前位置:网站首页>List collection implements paging
List collection implements paging
2022-06-29 06:52:00 【seven billion two hundred and fifty-eight million two hundred a】
List Collection implementation paging
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;
}
}
This article is for study and exchange only , Deletion of infringement contact .
边栏推荐
- [C language] flexible array
- VerilogA——动态比较器
- Difference between URI and URL
- UVM authentication platform
- Why is there a packaging type?
- QT (x): packaging and deployment
- Antlr4 recognizes the format of escape string containing quotation marks
- Monitor employee turnover dynamics. This system makes employees tremble!
- Illustrate plug-in -- AI plug-in development -- creative plug-in -- astute graphics -- path width style function
- Principle of screen printing adjustment of EDA (cadence and AD) software
猜你喜欢

json tobean

Illustrate plug-in -- AI plug-in development -- creative plug-in -- astute graphics -- length and angle measurement function

百度小程序自动提交搜索

json tobean

package. Are you familiar with all configuration items and their usage of JSON

Small program large screen adaptation Guide

【OSPF引入直连路由时巧借静态黑洞路由做汇总】

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

Labor skills courses integrated into steam Education

Design and practice of kubernetes cluster and application monitoring scheme
随机推荐
JDBC连接数据库,socket发送客户端。
Mongodb sort function
用机器人教育创造新一代生产和服务工具
Games101 Lecture 10 geometry 1 Notes
Fresnel diffraction with rectangular aperture based on MATLAB
Character pointer as function parameter
Introduction to Ceres Quartet
Difference between URI and URL
WDCP accesses all paths that do not exist and jumps to the home page without returning 404
2022.02.15 - 240. Lucky number in matrix
Go basic data type conversion
2022.02.15 - SX10-31. House raiding III
Can I cast int to a variable of type byte? What happens if the value is larger than the range of byte type?
MySQL learning notes
Multithreading tool class completabilefuture
json tobean
Convert data frame with date column to timeseries
VerilogA——计数器
Servlet version conflict causes page 404
Li Kou daily question - day 30 -1523 Number of bit 1