This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

total number of rows in a multidimensional array

 
nitinram agarwal
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 129
Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bigMatrix.length will give you the total no. of rows.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12185
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nitinram agarwal wrote:I have a multidimensional array

Actually, you don't. You have a one-dimensional array. It just happens to hold...arrays.
 
nitinram agarwal
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks everyone. i knew that i might be asking something silly but kind of got a little confused.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic