Alstresh Alstresh - 7 months ago 55
Java Question

java paging util

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)