0

It is possible in processing to initialize and declare a one dimensional array in two steps, or in one.

int []a;

a= new int[100];

which is equivalent to :

int [] a=new int [100];

I would like to know if there is a similar method as above to do the same for 2 dimensional array.

int [][] array= new int[100][200];
4

1 回答 1

1
// this??

int[][] a;

a = new int [100][200];

println("a.\'x\' length: " + a.length);
println("a.\'y\' length: " + a[0].length);

//or maybe... this?

int[][] b;

b = new int [100][];


for(int i = 0; i < b.length; i++){
  b[i] = new int[200];
}

println("b.\'x\' length: " + b.length);
println("b.\'y\' length: " + b[0].length);

当然你知道你也可以有一个二维数组列表

于 2013-10-23T12:47:34.240 回答