File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes total number of rows in a multidimensional array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "total number of rows in a multidimensional array" Watch "total number of rows in a multidimensional array" New topic
Author

total number of rows in a multidimensional array

nitinram agarwal
Ranch Hand

Joined: Jan 29, 2009
Posts: 83
Hello everyone,
I have a multidimensional array and would like to know what is the depth of it? For ex given the following 2 dimensional array


the total number of rows is 6. I would like to know if there is a direct way of determining the depth of a multi dimensional array. As of now, I am iterating through the array and computing it. for a one dimensional array, "length" gives me the total number of columns and I am looking towards something similar for row numbers.
Nitin Surana
Ranch Hand

Joined: Jan 21, 2011
Posts: 129

bigMatrix.length will give you the total no. of rows.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11256
    
  16

nitinram agarwal wrote:I have a multidimensional array

Actually, you don't. You have a one-dimensional array. It just happens to hold...arrays.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
nitinram agarwal
Ranch Hand

Joined: Jan 29, 2009
Posts: 83
thanks everyone. i knew that i might be asking something silly but kind of got a little confused.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: total number of rows in a multidimensional array