+ 1

Its 2 dimensional array or 3?

int[ ][ ] myArray = {{1,2,3}, {4}, {5,6,7}} ??? According to declaration...must be: int[ ][ ] myArray = {{1,2,3}, {4}}

14th Jan 2018, 12:47 PM
Hekmat Zaheer
Hekmat Zaheer - avatar
5 Réponses
+ 15
1d array means , set containing list of elements of same type 2d array means , set of 1d arrays 3d array means , set of 2d arrays //mine own definitions , but makes easy to visualise them😂
14th Jan 2018, 1:14 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 3
the two brackets after int says that the array is two dimensional. it has nothing to do with hiw many elements you store in them
14th Jan 2018, 1:11 PM
Jeremy
Jeremy - avatar
+ 1
we have: int[ ][ ] myArr = {{1,2,3},{4},{5,6,7}} {1, 2, 3} belongs to first [ ] and {4} belongs to second [ ] ok! but this brackets {5, 6, 7 } belongs to which [ ]???
14th Jan 2018, 1:07 PM
Hekmat Zaheer
Hekmat Zaheer - avatar
+ 1
2D array is like a table, although each row can have different number of columns your array is: ------- 1 2 3 4 5 6 7 ------- so it is 2-dimensional you can add as many rows as you like (if enough memory)
14th Jan 2018, 3:21 PM
michal
0
what do you mean?
14th Jan 2018, 12:50 PM
Jeremy
Jeremy - avatar