If you have worked with languages like C, C++ or C# then you must be aware with the concept of multidimensional array. Multidimensional array implies arrays of array. In a two dimensional array, there would be rows and columns. A 3*5 two dimensional array can be shown as below,
In above code
First we defined a base array
Then we created two chid arrays. These arrays will constitute different rows of the base array.
Each child array is of different size.
Assigning each chid array as one of the rows of base array.
In last line of above code listing, we are printing value of 1st row and 4th column of base array. We will get output as following,
In above code listing,
We are defining array named grandparents. This is the base array.
We are defining array named parents. Grandparents can have parents.
We are defining array names child. Parents can have child.
We want to print “steve”. Steve is second element of child2 array. child2 array is second element of parents1 array. parents1 array is first element of grandparents array. so we can fetch steve with following index value on grandparents array
As output you will get steve printed as following,