+ 5
Multidimensional Arrays
Can someone explain these to me please. int[][] arr = new int[5][10] I understand the above but I dont understand what comes after that. When you iterate through the array to get certain values I get very confused. Please help, thx
6 Réponses
+ 14
It's just the initialisation of multidimentionnal array.
5 and 10 is the length of array.
For now, array are empty.
+ 12
Yes. For iterate a multi array, need 2 or more for.
+ 2
java is similar I guess, was looking for java answer but the loop process is the same just not the cout stuff. iam still confused but thx to all who helped thus far
+ 1
think of it as a list inside a list.
So, int[][]_2D_array = new int[m][n] would mean an (empty) array (_2D_array) of size m*n that will contain two lists/arrays.
You'll need 2-loops (for loop is common) to access elements in _2D_array. The first tracks indices of first list ([m]) and the second loop handles that of [n].
You could print a matrix of M x N with this logic