展开全部
有两种实现方法:可以用e68a843231313335323631343130323136353331333337623534List数组来实现
可以用map来实现
方法一:用map来实现
比如要创建一个1行、3列的数组,实现方法如下:
public static void main(String[] args) throws CloneNotSupportedException {
Map> myMap = create(1, 3);
}
public static Map> create(double row, double column) {
Map> doubleMap = new HashMap>();
for (double x = 0; x < row; x++) {
for (double y = 0; y < column; y++) {
doubleMap.put(x, new ArrayList());
}
}
return doubleMap;
}
方法二:
可以用List数组来实现
public static void main(String args[]) {
//list 作为动态二维数组
List> list = new ArrayList();
List a1 = new ArrayList();
List a2 = new ArrayList();
List a3 = new ArrayList();
list.add(a1);
list.add(a2);
list.add(a3);
a1.add("string1 in a1");
a1.add("string2 in a1");
a2.add("string1 in a2");
a3.add("string1 in a3");
a3.add("string2 in a3");
for (int i = 0; i
for (int j = 0; j
System.out.println(list.get(i).get(j));
}
}