Is it possible to change the dimensions of a two dimensional array in Processing?
int m = 4;
int n = 6;
int [][] nums = new int[2][3]; //right now the array has 2 rows and 3 columns
//code that changes the dimensions of the array to m x n
//setting nums.length and nums[0].length to m and n doesn't work, I tried it already
println(nums.length); //should be 4
println(nums[0].length); //should be 6
Here is an exact copy of the question:
Modify 2nd Dimension Write the following function:
void setDim(int[][] x, int m) {}
That changes the number of columns in each row of x to m.
Edit: I checked the answer, and the code that goes in the middle is
for(int i = 0 ; i < x.length; i++) x[i] = new int[m];
can someone explain this?