I worked with relatively large arrays Stringtoday. (Approximately 400 x 400) I was wondering how to make one array equal to another. For instance,
String[][] array1 = new String[400][400];
String[][] array2 = array1;
Does one array equal to another the same as loop through each element and makes it equal to the corresponding position in another array? (As shown below)
for(int y = 0; y < 400; y++) {
for(int x = 0; x < 400; x++) {
array2[x][y] = array1[x][y];
}
}
Now the looping method is similar to how one array is equal to another? Or is the first / second faster than the other? Personally, I believe that the former would be faster just because there is no recursion or the need to manually allocate memory for array2before recursion. But I don’t know where to start looking for this information, and I would like to understand the logic of how Java handles such things.
source
share