static <T> List<List<T>> convertToNList(List<T> list, int numberOfList) {
int countPerList = 1;
while (countPerList * numberOfList < list.size()) {
countPerList++;
}
return convertToNContainingList(list, countPerList);
}
static <T> List<List<T>> convertToNContainingList(List<T> list, final int countPerList) {
List<List<T>> result = new ArrayList<List<T>>();
final int N = list.size();
for (int i = 0; i < N; i += countPerList) {
result.add(new ArrayList<T>(list.subList(i, Math.min(N, i + countPerList))));
}
return result;
}