Can some provide me some clarity on Multidimensional Arrays | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can some provide me some clarity on Multidimensional Arrays

Java

1st Mar 2017, 9:26 PM
Demetrius L. Bolden
Demetrius L. Bolden - avatar
3 Answers
+ 11
Example from previous posts: int[ ][ ] myArr = { {1, 2, 3}, {4}, {5, 6, 7} }; myArr[0][2] = 42; int x = myArr[1][0]; // 4 Write it down as a table to understand it: 1 2 3  |    a [0][0]   a [0][1]   a [0][2] 4         |    a [1][0] 5 6 7  |    a [2][0]   a [2][1]   a [2][2] In every bracket pair there is one row of the 'table', the columns result from that. The elements can be accessed as shown above. First number stands for the row and second number for the column.
1st Mar 2017, 9:38 PM
Tashi N
Tashi N - avatar
+ 9
consider the matrix | a b |----> rows | c d | | v columns •this consists of rows and columns •each element within the matrix is refered by its row and column •considering element a which is represented by 1st row and 1st column •since we consider the two parameters to refer to the element we consider it to be multidemensional. •there can be more than 2 dimensions as well .
1st Mar 2017, 9:37 PM
Akshata
Akshata - avatar
0
I understand how the complier start to count from 0 but how did the value of the array valued 4?
2nd Mar 2017, 4:23 AM
Demetrius L. Bolden
Demetrius L. Bolden - avatar