array out of bounds exception

A

ap

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=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[j] " + avList[j].length);
avList[j]=new myType_T[innerSize];

log.info("past new of innersize");

for (int k=0; k < innerSize; k++) {
log.info("k= "+ k);
avList[j][k]=getmyType_T();
}
}

}
return avList;

}
 
E

Eric Sosman

ap wrote On 09/05/06 17:35,:
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

It would have been helpful if you'd pointed out the line
where the exception occurs, but I think I've spotted it anyhow.
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=new NameAndStringValue_T[outerMostSize][outerSize];


avList = new MyType_T[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[j] " + avList[j].length);
avList[j]=new myType_T[innerSize];

log.info("past new of innersize");

for (int k=0; k < innerSize; k++) {
log.info("k= "+ k);
avList[j][k]=getmyType_T();
}
}

}
return avList;

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top