Array Manipulation
Learn to manipulate multidimensional arrays.
We'll cover the following...
We'll cover the following...
Nested loops for a 2D array
An important factor we should always keep in mind is that according to the depth of the multidimensional array, we can always use the nested for loop. Consider the following example, where we have 2D arrays.
Based on its dimension, we use one nested for loop.
We get the following output when we run the code above:
0 => 1 2 3
1 => 4 5 6
2 => 7 8 9
In the above Java code:
Line 14: This line of code traverses and prints a myArray[i][j] named 2D array using the indexes i and j.