I have List of Object. I need to do pagination.
The input parameters are the maximum number object per Page and Page number.
For example input list = ("a", "b", "c", "d", "e", "f")
The maximum number per Page is 2
Page number is 2
Result = ("c", "d")
Are there any ready-made classes(libs) to do this? For example Apache project or so on.
int sizePerPage=2;
int page=2;
int from = Math.max(0,page*sizePerPage);
int to = Math.min(list.size(),(page+1)*sizePerPage)
list.subList(from,to)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With