0

Two dimensional array

int[ ][ ] myArr = { {1, 2, 3}, {4}, {5, 6, 7} }; Does this array creates a table like below 1 2 3 4 5 6 7 Can anyone explain why is this called Two dimensional array ? is this just because we have got 2 sets of square brackets while declaring an array?

21st Feb 2017, 7:46 PM
Yoganand
1 Resposta
+ 4
You can print your array with System.out.println(Arrays.deepToString(myArr)); if you're confused, see: https://code.sololearn.com/cxeAUcPMnQcH/?ref=app In Java a 2d array is an array inside an array, that explains the brackets ^.^ In each bracket pair inside the first array you define the rows and the columns result from that definition. Always helps me to see a 2d array as a table, so I don't get confused to access the values...
21st Feb 2017, 8:11 PM
Tashi N
Tashi N - avatar