public class Main {
public static void main(String[] args) {
List<String> ids = new ArrayList<>();
for(int i = 0;i < 2009; i++){
ids.add(String.valueOf(i));
}
int seed= 1000;
int flag = 0;
List<List<String>> splitedIds = new ArrayList<>();
for(int i = 0; i < ids.size(); i++){
if(i==0){
splitedIds.add(new ArrayList<>());
}else if(i%seed == 0){
splitedIds.add(new ArrayList<>());
flag++;
}
splitedIds.get(flag).add(ids.get(i));
}
for(List<String> list : splitedIds){
System.out.println(list.size());
}
}
}
java-把list按制定条数划分为多份
最新推荐文章于 2024-09-02 16:13:34 发布