title: Rotate array clockwise
body: <p>I have a two dimensional array that I need to rotate 90 degrees clockwise, however I keep getting arrayindexoutofbounds...</p>
  <pre class="lang-java prettyprint-override"><code>public int[][] rotateArray(int[][] arr) {
      // first change the dimensions vertical length
      // for horizontal length and vice versa
      int[][] newArray = new int[arr[0].length][arr.length];
  
      // invert values 90 degrees clockwise by starting
      // from button of array to top and from left to right
      int ii = 0;
      int jj = 0;
      for (int i = 0; i &lt; arr[0].length; i++) {
          for (int j = arr.length - 1; j &gt;= 0; j--) {
              newArray[ii][jj] = arr[i][j];
              jj++;
          }
          ii++;
      }
      return newArray;
  }
  </code></pre>