Matrix size Java

I have a matrix for example 5×10.

double[][] matrix = new double[5][10]

I would like to know the size of these matrix, But if I do it:

matrix.length

It only return me columns size: 10

How could I do it?

Answer

matrix.length gives you the number of rows.

matrix[0].length gives you the number of columns (assuming all rows have the same length).

Leave a Reply

Your email address will not be published. Required fields are marked *