[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: array question



test.length would return 200 (? or only the number of elements
initialized)
so would not test[i].length return what you want? (i being an
initialized element)
Be careful how you do this because Java allows multi-dimensional arrays
to have a different 2nd value for each 1st value. ie.
test[0] contains 8 values, but test[1] contains only 3 values. If you
use test[0].length as the length of all subsequent arrays, you would get
an out of bounds exception when trying to access test[1][3] because
test[1] only has values in test[1][0], test[1][1] and test[1][2] (3
values).
Ed.

Bill Woodson wrote:
> 
> Hi All,
> 
> How do get the length of dimensions of a multi dimensional array that are
> not the first dimension? In other words I want to get the second dimension
> length of "int [][] test=new int[200][100];" which in this case is 100.
> 
> Thanks,
> Bill