I have an array that I need to split in different arrays. I have an array of Strings and need to split it in different pages (different arrays).
At first, I get the length of the array, using
int size = array.length;
And then, I get the number of pages I need, knowing that each page should only have 10 Strings
int numberOfPages = (int) Math.floor(size/10);
The user then select which page he wants to see
int pageSelected = 2;
After that, I tried to split the array, but got some exceptions. I tried:
Arrays.copyOfRange(array,(0+10*(pageSelected-1),10*10+(pageSelected-1)));
I get an exception when I try to print the values of the new array.
Is there anyway to split an array in 'pages', and display these 'pages' as requestes?
@Edit1 I get a Nullpointer Exception
Math.ceil((double) size/10)because an integer division already floors.