title: How do i solve this array and loop? correct output but
body: <p>My objective is to write a loop that sets newScores to oldScores shifted once left, with element 0 copied to the end.</p>
  
  <p><strong>Edit</strong>: Here's my main problem, I initialized <code>newScores[3] = oldScores[0];</code> but the thing is the for loop makes <code>i = 4</code> when there's no oldScores[4] or newScores[4] but since I initialized newScores[3] to oldScores[0] it compiles and runs, but the problem is that [4] is not in the array at all. How do i get rid of this problem? I'm so close but so far away it's bugging me.</p>
  
  <p>Example:</p>
  
  <pre><code>If oldScores = {10, 20, 30, 40}, then newScores = {20, 30, 40, 10}
  </code></pre>
  
  <p>Funny thing is I have the correct output but the learning website I'm using it tells me that I have the correct output but it also displays this "Runtime error (commonly due to an invalid array/vector access, divide by 0, etc.). Tests aborted.".</p>
  
  <pre><code>public class StudentScores {
     public static void main (String [] args) {
        final int SCORES_SIZE = 4;
        int[] oldScores = new int[SCORES_SIZE];
        int[] newScores = new int[SCORES_SIZE];
        int i = 0;
  
        oldScores[0] = 10;
        oldScores[1] = 20;
        oldScores[2] = 30;
        oldScores[3] = 40;
        newScores[3] = oldScores[0];
        for(i=0; i&lt;SCORES_SIZE-1; i++){
           newScores[i] = oldScores[i +1];
        }
  
        for (i = 0; i &lt; SCORES_SIZE; ++i) {
           System.out.print(newScores[i] + " ");
        }
        System.out.println();
  
        return;
     }
  }
  </code></pre>