title: Moving array elements left and right
body: <p>So as part of the <code>Vector</code> class I'm trying to create, I also want the ability for the user to be able to shift the elements in the array an <code>'n'</code> number of places depending on what is specified. If the user inputs a number that is larger than the array size, then the elements continue shifting back to the start and moving. An example would be:</p>
  
  <pre><code> 1 2 3 4 (shifted 1) =&gt; 4 1 2 3
  
   1 2 3 4 (shifted 4) =&gt; 1 2 3 4
  
   1 2 3 4 (shifted 5) =&gt; 4 1 2 3
  </code></pre>
  
  <p>I don't have much code so far except:</p>
  
  <pre><code>public Vector shifted(int amount) {
    Vector vectorShifted = new Vector(length);
  
    for (int i = 0; i &lt; length; i++);
      vectorShifted.elements[i] = this.elements[i + amount]
    }
    return vectorShifted;
  }
  </code></pre>
  
  <p>However, when I run this program and a number greater than <code>length</code> is entered, an error is displayed. Is there a way of modifying this code in that any number, positive or negative can be inputted and shift the values across?</p>