Hi all,
I've got a routine that initializes a 3-dimensional array in which
the sizes of the arrays are read in at run-time followed by the values.
I get the infamous array out of bounds exception. Anything wrong?
THANKS
public myType_T[][][] getData_T()
{
myType_T[][][] avList={} ;
int outerSize=0; int innerSize=0; int outerMostSize=0;
// Get dimension of outermost sequence
outerMostSize=getLength();
log.info("number of outer most sequence elements " +
outerMostSize);
if (outerMostSize==0)
{
return avList;
}
avList= new myType_T [outerMostSize][][];
for (int i=0; i < outerMostSize; i++)
{
log.info("i= "+ i);
outerSize=getLength();
log.info("number of outer sequence elements " + outerSize);
avList[i]=new NameAndStringValue_T[outerMostSize][outerSize];
for (int j=0; j < outerSize; j++)
{
log.info("j= "+ j);
innerSize =getLength();
log.info("number of innermost sequence elements " +
innerSize);
log.info("size of a[i][j] " + avList[i][j].length);
avList[i][j]=new myType_T[innerSize];
log.info("past new of innersize");
for (int k=0; k < innerSize; k++) {
log.info("k= "+ k);
avList[i][j][k]=getmyType_T();
}
}
}
return avList;
}
Andrew Thompson - 06 Sep 2006 06:28 GMT
...
> avList[i]=new NameAndStringValue_T[outerMostSize][outerSize];
I suspect this needs to be..
avList[i]=new NameAndStringValue_T[outerSize];
..if not, you might try wrapping that snippet in a few extra
lines and making it a compilable example, rather than
forcing the reader to 'guess' which of the three array
assignments is causing the problem.
Andrew T.