Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are several errors in your code.</p> <p>First, a better name for the circles class would be Circle. Java classes are typically capitalized and singular, not plural.</p> <p>Next, your for loop is going too far. Your array has 10 elements, but arrays in Java are zero-indexed. This means that the first element in circles_test is <code>circles_test[0]</code>, the second is <code>circles_test[1]</code>, and so on. But <code>circles_test[10]</code> doesn't exist, because that would be the 11th element in your array of size 10. This causes the ArrayIndexOutOfBoundsException, because you are trying to use the index 10, which is too big. This is happening because you wrote this in your for loop:</p> <pre><code>i &lt;= circles_test.length </code></pre> <p>This means that <code>i</code> will go all the way up to and including <code>circles_test.length</code>. But we don't want it to go to 10, because that index is out of bounds, so remove the <code>=</code> sign.</p> <p>Next, a better way to write your for loop is to include the increment statement in the loop like so:</p> <pre><code>for(i=0; i &lt; circles.length; i++) { } </code></pre> <p>For loops work like this:</p> <pre><code>for(first_statement; second_statement; third_statement) </code></pre> <p><code>first_statement</code> will happen once at the beginning of the loop. <code>second_statement</code> will be checked once each time at the beginning of one repetition of the loop, and if it is false, the loop will end. <code>third_statement</code> will happen each time at the end of the loop.</p> <p>If you have any more questions feel, free to ask.</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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