I don’t know why this is generating an ArrayOutOfBoundsException! It’s likely I’ve overlooked something because I’m so tired but if someone could tell me what is wrong I’d appreciate it. Thanks.
// array declaration
public int CircleLeft[] = new int[mIPAWidth];
// this is my loop that generates the error:
for(px = 0; px <= mIPAWidth - 1; px++){
py =(int) m.sqrt(r^2 - (px-mIPAWidthHalf)^2) + mIPAHeightHalf;
Log.w(getClass().getName(), "mIPAWidth = " + mIPAWidth + ", index is: " + px);
CircleLeft[px] = py; }
Along with Luther Blissett’s answer…
Are you modifying
mIPAWidthbetween when the array is instantiated and when you begin theforloop? I would change yourforconditional to something like this:That way you know the type of
pxand you know you’re referencing the actual length of theCircleLeftarray. It may not fix your error, but it’s still a good idea.