先定义一个 ArrayLIst 的数组
然后在 构造函数中 做个循环 逐个new出来
参考代码 如下:
package test;
import java.util.ArrayList;
public class Test {
ArrayList[] list = new ArrayList[20];
Test() {
for (int i = 0; i < 20; i++) {
list[i] = new ArrayList();
}
}
}
那你为啥不用array呢??
ArrayList newArrayList = new ArrayList(20);
ArrayList(int initialCapacity)
Constructs an empty list with the specified initial capacity.
那你为啥不用array呢??
ArrayList newArrayList = new ArrayList(20);
ArrayList(int initialCapacity)
Constructs an empty list with the specified initial capacity.
回答者: xumu_1983 - 都司 七级 4-16 21:22
可以写一个循环程序啊
回答者: yiyue68 - 试用期 一级 4-16 23:26
先定义一个 ArrayLIst 的数组
然后在 构造函数中 做个循环 逐个new出来
参考代码 如下:
package test;
import java.util.ArrayList;
public class Test {
ArrayList[] list = new ArrayList[20];
Test() {
for (int i = 0; i < 20; i++) {
list[i] = new ArrayList();
}
}
}
回答者: bblntu - 助理 二级 4-17 10:41
可以写一个循环程序啊