title: How to rotate 3x3 2d array clockwise by n times
body: <p>These are my loop statements. The first loop displays the non-rotated block while the second loop rotates and displays the 2d array by n(user input) times. My problem is that the 2d array will rotate once but will not rotate the third and following times around. I want my 2d array to rotate 90 degrees clockwise every time it is displayed.</p>
  
  <pre><code>        rot = x.nextInt(); //user input for n rotations
          //initial block
          System.out.println("1");
          for(i=0; i&lt;block.length; i++)
              {
                  for(j=0; j&lt;block[i].length; j++)
                      System.out.print(block[i][j]+"\t");
                  System.out.println();
              }
          //rotated block
          for(cnt=2; cnt&lt;=rot; cnt++)
          {
              System.out.println(cnt);
              for(i=0; i&lt;block.length; i++){
                  for(j=block.length-1; j&gt;=0; j--){
                      newBlock[i][j] = block[j][i];
                      System.out.print(newBlock[i][j]+"\t");
                  }
                  System.out.println();
              }
          }
  </code></pre>