List<Integer> list=new ArrayList<Integer>();
for(int i=1;i<30;i++)
{
list.add(i);
}
int pagesize=2;
int totalcount=list.size();
int pagecount=0;
if(totalcount%pagesize==0) pagecount=totalcount/pagesize;
else pagecount = totalcount/pagesize+1;
for(int i=1;i<=pagecount;i++){
if (pagecount==0){
List<Integer> subList= list.subList((i-1)*pagesize,pagesize*(i));
System.out.println(subList);
}else{
if (i==pagecount)
{
List<Integer> subList= list.subList((i-1)*pagesize,totalcount);
System.out.println(subList);
}else
{
List<Integer> subList= list.subList((i-1)*pagesize,pagesize*(i));
System.out.println(subList);
}
}
}
for(int i=1;i<30;i++)
{
list.add(i);
}
int pagesize=2;
int totalcount=list.size();
int pagecount=0;
if(totalcount%pagesize==0) pagecount=totalcount/pagesize;
else pagecount = totalcount/pagesize+1;
for(int i=1;i<=pagecount;i++){
if (pagecount==0){
List<Integer> subList= list.subList((i-1)*pagesize,pagesize*(i));
System.out.println(subList);
}else{
if (i==pagecount)
{
List<Integer> subList= list.subList((i-1)*pagesize,totalcount);
System.out.println(subList);
}else
{
List<Integer> subList= list.subList((i-1)*pagesize,pagesize*(i));
System.out.println(subList);
}
}
}