next up previous
Next: Example: printing out the Up: Unit 07 Previous: Expressions that denote matrix

Number of rows and columns of a matrix

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

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


next up previous
Next: Example: printing out the Up: Unit 07 Previous: Expressions that denote matrix