日期:2014-05-20 浏览次数:20963 次
public static void main(String[] args) { int count = 1000; int index = 0; List<Integer> list = new ArrayList<Integer>(); for (int i = 0; i < count; i++) { list.add(i+1); } for (int i = 0; i < 20; i++) { List<Integer> temp = list.subList(index, index+count/20); index += count/20; System.out.println("the data of list " + (i + 1) + "===========>"); for (int j = 0; j < temp.size(); j++) { System.out.println(temp.get(j)); } } }
------解决方案--------------------
List<Integer> list=new ArrayList<Integer>(); for(int i=1;i<1001;i++) list.add(i); int count=list.size()/20; for(int i=0;i<20;i++){ List<Integer> subList= list.subList(i*count,count*(i+1)); System.out.println(subList); }