wood burning stoves
The moose likes Beginning Java and the fly likes multidimensional array length Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "multidimensional array length" Watch "multidimensional array length" New topic

multidimensional array length

Tyler Jordan
Ranch Hand

Joined: Nov 17, 2003
Posts: 70
I am having trouble getting the length of the first dimension in a multidimensional array. I have the following array.


I found some info on the net saying if I want to get the first dimension's length I do:


However, when I compile I get:

cannot resolve symbol
method length()

Above this part of the code I have a length method that is working fine on the same array, however I am using the following format:

Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
The second one that seems to work is actually calling length() on the object at the cell [x][y] which must be a String or something that has a length() method. Array doesn't have a length() method, it has a length attribute - no parens. You'd have to call the inventors of the language to ask why some things have length, others have length() and others have size().

Remembering that a multi-dimensional array is just an array of arrays ...

[ May 19, 2005: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link: http://aspose.com/file-tools
subject: multidimensional array length
It's not a secret anymore!