title: How to rotate an array right
body: <p>I have wrote a program to shift an int array left, but cannot find a way to move it right. Could you take a look at my code and comment if you have any ideas how how to "rotate" my array right based on the number of spaces (int x), as currently it only moves left. Thanks</p>
  
  <pre><code>public void makeRight(int x) {
     int[] anArray = {0, 1, 2, 3, 4, 5};
     int counter = 0;
     while (counter &lt; x) {
          int temp = anArray[0];
          for (int i = 0; i &lt; anArray.length - 1; i++) {
              anArray[i] = anArray[i + 1];
           }
  
           anArray[anArray.length - 1] = temp;
           counter++;
    }
    for (int i = 0; i &lt; anArray.length; i++){
        System.out.print(anArray[i] + " ");
    }
  }
  </code></pre>