注:这里的List类是我自己写的一个类,不是ArrayList类。
这个程序中的 list1 这个多维数组最大可以到几维,还是说维度可以无限大。
public class test {
public static void main(String[] args) {
List list1=new List(0, new List("1")); // list1 = { 0, { "1" } }
List interm=list1;
while (true){
String a="1";
interm=(List) interm.getElement(1); // First loop: interm = list1[1] = {1}
interm.append(new List(a)); // First loop: interm = { "1", { "1" } }; list1 now change to { 0, { "1", { "1" } } }
}
}
}