Note that there are some explanatory texts on larger screens.

plurals
  1. POValue (not index) greater than 3 in array causes java.lang.ArrayIndexOutOfBoundsException
    primarykey
    data
    text
    <p>I'm a novice programmer. This may be a simple problem but I've never seen this before. First of all, let me clarify that I'm not even trying to manipulate the index. Here's the part of the code that is causing the exception:</p> <pre><code> int[] bumpercatcher = new int[4]; //time variable that helps control events int time = 0; public void setup() { bumpercatcher[0]=4; bumpercatcher[1]=4; bumpercatcher[2]=4; bumpercatcher[3]=4; </code></pre> <p>As you can see I'm trying to set them all equal to 4 at the start of the program. This causes the arrayindexoutofbounds exception. If I set them all equal to 0~3 then there is no problem (until I set them to a value greater than 3 later in the program). I don't understand it.</p> <p>-it doesn't matter if I set the array size to 10, I still get the same exception</p> <p>-it doesn't matter if I set only one of the values (i.e. at index 1, which is <strong>definitely</strong> within bounds of the array). same exception</p> <p>Is there something I'm doing wrong? Thanks.</p> <p>well, here' the entire code if you want to take a look(not too long, 1 class, bad programming practies): <a href="http://dl.dropbox.com/u/33501308/Pong.java" rel="nofollow">http://dl.dropbox.com/u/33501308/Pong.java</a></p> <p>Here's the html from which you can see the program from (not much to see. it just freezes instantly.): <a href="http://dl.dropbox.com/u/33501308/bin.zip" rel="nofollow">http://dl.dropbox.com/u/33501308/bin.zip</a></p> <p>by the way I'm using eclipse.</p> <p>I don't really know what SSCEE is. sorry</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload