0

How best can I understand multidimensional arrays?

So, I understand what arrays are. However, I can not seem to find an easy way to understand multidimensional arrays. Can any body offer any guidance?

23rd Jun 2016, 1:35 PM
Bruce William Opio
Bruce William Opio - avatar
4 Respostas
+ 1
Single dimension arrays are used to store a objects of same type. For eg: To store employees record or students record. Assume the case if you want to store students/employees informations from various departments. So multidimensional array comes in the picture. For eg: Info _info [10][20]; Here first dimension (10) represents the number of department and second dimension (20) represents number of students in that particular department. _info [0] pointing to the first department students information. _info [2][3] pointing to the third department and 4 student information. if you want to intialize the 2d array, you can achieve like this info[][] = {{dept1stu1, dept1stu2,....}, {dept2stu1, dept2stu2,...}, {.....}, {.....}, ....... }; info[1][0] is pointing to dept2stu2. Hope this helps you to understand and usage for multidimensional Array. NOTE: There is a better way to save these information, just to demonstrate the multidimensional array I have used it here
24th Jun 2016, 7:04 AM
Venkatesh(Venki)
Venkatesh(Venki) - avatar
+ 1
@krishna...what if I define 5 dimension array? then?? how will you show it through matrix?
26th Jun 2016, 2:12 PM
Mukul Kumar
Mukul Kumar - avatar
0
The best and better way to understand multidimension array is by matrix
23rd Jun 2016, 3:52 PM
Krishna Gupta
Krishna Gupta - avatar
0
In a simple array, the elements are single elements. In a multidimensional array, the element are another arrays. int[] arr1 = { 1,2,3 }; int[] arr2 = { 3,4,5 }; int[][] multiArr = new int [][] {arr1, arr2};
23rd Jun 2016, 3:59 PM
Erwin Mesias
Erwin Mesias - avatar