How can we find the total size of multidimensional array?

class Array15
{
public static void main(String[] args)
{
int[][] x=new int[5][3];
System.out.println(x.length);
System.out.println(x[0].length);
}
}
/*
Output:- 5 3
Explanation:- In multidimensional arrays length variable represents only base size but not
total size. There is no direct way to find total length of multidimensional
arrays but we can find indirectly as follows.
x[0].length+x[1].length+x[2].length+........

*/

0 comments: