Alstresh Alstresh - 1 year ago 108
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.

Answer Source
int sizePerPage=2;
int page=2;

int from = Math.max(0,page*sizePerPage);
int to = Math.min(list.size(),(page+1)*sizePerPage)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download