Thanks for your immediate responses. My requirement is this. I have a page where i'll display the list of applications to the user in 3 columns. I have the application object arraylist. how will i equally split the objects across the 3 columns.
If i have 9 applications, i can divide it by 3 and display them as 3 per each column. What will i have to do if my list has 8 objects.
This is my code:
int size = filteredAppLst.size();
int column1=0;
int column2=0;
int val = size%3;
int checkValue = 0;
if(val == 0){
checkValue = size/3;
}else{
checkValue = size%3;
}
for (int i = 0; i < filteredAppLst.size(); i++) {
Application app = (Application) filteredAppLst.get(i);
String name = app.getName().toLowerCase();
if(column1 != checkValue){
column1Lst.add(app);
column1++;
}else if(column2 != checkValue){
column2Lst.add(app);
column2++;
}else{
column3Lst.add(app);
}
}