Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

array out of bounds exception

Thread view: 
ap - 05 Sep 2006 22:35 GMT
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;
   
}
Eric Sosman - 05 Sep 2006 22:47 GMT
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()
> {
[quoted text clipped - 20 lines]
>          log.info("number of outer sequence elements " + outerSize);
>          avList[i]=new NameAndStringValue_T[outerMostSize][outerSize];

   avList[i] = new MyType_T[outerSize][];

>          for (int j=0; j < outerSize; j++)
>          {
[quoted text clipped - 19 lines]
>      
> }

Signature

Eric.Sosman@sun.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.