Using the variable length, it is possible to obtain the number of rows and of columns of a matrix. Let m be a reference to a matrix (i.e., an array of arrays). Then
Note: If all rows have the same number of columns (as in the previous example), we can simply use m[0].length.
Example:
double[][] v; v = new double[15][20]; System.out.println(v.length); // prints out 15 System.out.println(v[0].length); // prints out 20