> Hi
>
[quoted text clipped - 9 lines]
> it being an array of an array of an array(3x), if one value is not
> specified, how can you tell?
The first index refers to the outer array, the next to the next inner
array, etc.
If you don't know in advance how long each array is, then you must check
lengths before accessing an element.
For example, to access arr[1][2][3], do this:
if (arr.length >= 2) {
String [][] arr0 = arr[1];
if (arr0.length >= 3) {
String [] arr1 = arr0[2];
if (arr1.length >= 4) {
String arr2 = arr1[3];
// use the value here
}
}
}
This is ugly. I'm sure you can find a more efficient way to do it.
Lew - 09 Mar 2008 23:04 GMT
> If you don't know in advance how long each array is, then you must check
> lengths before accessing an element.
Worse, you have to check for null, too.
> For example, to access arr[1][2][3], do this:
if ( arr != null && arr.length >= 2) {
> String [][] arr0 = arr[1];
if ( arr0 != null && arr0.length >= 3) {
> String [] arr1 = arr0[2];
if ( arr1 != null && arr1.length >= 4) {
> String arr2 = arr1[3];
> // use the value here
// checking for null
> }
> }
> }
>
> This is ugly. I'm sure you can find a more efficient way to do it.

Signature
Lew