IndexOutOfBounds: Why does low keep going past high : <p>I keep getting an IndexOutOfBounds error for the if statement down below and I don't know why. low is initially 0, high is set to 24, and the size of the ArrayList is 25. </p>

<pre><code>        for(int i = low + 1; low &lt;= high; i++){
                if(list.get(i).compareTo(list.get(pivIndex)) &lt; 0){ //this line
                E temp = list.get(pivIndex);
                list.remove(pivIndex);
                list.add(pivIndex, list.get(i));

                list.remove(i);
                list.add(i, temp);
            }
        }
</code></pre>
