0
Multidimensional arrays, two dimensional makes sense, but not much else.
Straight from solo learn's tutorial. Not sure how they work. I was able to do the first half of it. int[ ][ ] myArr = { {1, 2, 3}, {4}, {5, 6, 7} }; myArr[0][2] = 42; int x = myArr[1][0]; // 4 explain how this works, please!
3 Respuestas
+ 1
Brian Rowley two dimensional arrays are nothing but matrices which has rows and columns.
The matrix will look something like this-
1 2 3
4
5 6 7
myArr[0][2] is the element at 0th row and 2nd column which is 3. This will be replaced by 42.
myArr[1][0] is the element at 1st row and 0th column which is nothing but 4.
Remember just like array index are numbered from 0 to n-1 similarly the row and column are considered from 0. So your 1st row is 0th row and your 1st column is 0th column.