4 Replies Latest reply on Jul 1, 2010 3:52 PM by 843789

    ArrayIndexOutOfBoundsException

    843789
      I have this code in one of my classes
                tileArray = new int[9][9];
                
                i1 = 0;
                i2 = 0;
      
                while(i1 < 10)
                {
                     
                     if(i2 == 10)
                     {
                          
                          i2 = 0;
                          i1++;
                               
                     }
                     
                     if(i1 != 10)
                     {
                          
                          tileArray[i1][i2] = i1*i2;
                          i2++;
                          
                     }
                          
                }
      And for some reason when I run it it gives me the ArrayIndexOutOfBoundsException. I looked it up and it seems to be as its name says, it happens when you try to access an index larger(or smaller I suppose) than the one you have defined it for. I ran it through with println instead and it echos the range from 0,0 to 9,9 which is what I want, and what I have it defined for, so I'm not understanding why I'm getting this out of bounds exception.

      Anyone?
      Thanks,
      Farshief