Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matrix size Java

Tags:

java

I have a matrix for example 5x10.

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?

like image 898
cedra Avatar asked Apr 06 '15 14:04

cedra


1 Answers

matrix.length gives you the number of rows.

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

like image 145
Eran Avatar answered Oct 25 '22 11:10

Eran