public class CollectionSplitter {
static List split(List srcList, int index) {
List d = new ArrayList();
for (int i = 0; i < srcList.size(); i = i + 4) {
if ((i + 4) <= srcList.size())
d.add(srcList.subList(i, i + 4));
else
d.add(srcList.subList(i, srcList.size() - 1));
}
return d;
}
public static void main(
String[] args) {
List resultList = new ArrayList();
List list = new ArrayList();
list.add("one");
list.add("two");
list.add("three");
list.add("four");
list.add("five");
list.add("six");
list.add("seven");
list.add("eight");
list.add("nine");
list.add("ten");
list.add("eleven");
resultList = split(list, 5);
}
}
if there is still simple let me know