Array out of bounds Exception bowling example
<p>Hi guys can someone please tell me what this means? I'm writing a program for a game of bowling and my program compiles with no errors but when I run it , this part of the code is highlighted with the error: <code>java.lang.ArrayIndexOutOfBoundsException:-1</code></p>

<p>Here is my code:</p>

<pre><code>if(rolls[i]+rolls[i+1] == 10) {
    total = rolls[i]+rolls[i+1];
    isSpare = true;
}
</code></pre>

<p>Edit: Here is the entire for loop:</p>

<pre><code>for (int i = 0; i &lt; rolls.length; i += 2) {
    isStrike = false;
    isSpare = false;
    lastFrame = false;
    if (i == rolls.length - 3) {
        System.out.println("FINAL FRAME");
        lastFrame = true;
        total = rolls[i] + rolls[i + 1] + rolls[i + 2];
        frame[0] = rolls[i];
        frame[1] = rolls[i + 1];
        frame[2] = rolls[i + 2];
    }
    if (rolls[i] == 10) {
        total = rolls[i];
        frame[0] = rolls[i];
        isStrike = true;
        i -= 1;
    } else {
        total = rolls[i] + rolls[i + 1];
        frame[0] = rolls[i];
        frame[1] = rolls[i + 1];
    }
    if (rolls[i] + rolls[i + 1] == 10) {
        total = rolls[i] + rolls[i + 1];
        isSpare = true;
    }
    runningTotal = runningTotal + total;
    printFrame(frame, isStrike, isSpare, lastFrame, frames, runningTotal);
    frames++;
} //increment

System.out.println();
}
</code></pre>