title: flipping a multi-dimensional array java
body: <p>i have a class that creates a canvas of characters with a desired width and height.</p>
  
  <p>within this i have a method drawLetter() (which basically changes the characters so that a letter appears on the canvas (like very simple ASCII art)</p>
  
  <p>i have 3 other methods rotateClockwise, flipHorizontal, and flipVertical </p>
  
  <p>rotate and flipHorizontal i have done fine and they work but i cannot seem to work out where im going wrong with flipping the array vertically (out of interest i think i have horizontal and vertical the wrong way round but ill put a sample of what im trying to get done below)</p>
  
  <p>this is what i cant work out:</p>
  
  <p>this:</p>
  
  <pre><code># # # ~
  ~ # ~ ~
  ~ # ~ ~
  ~ ~ ~ ~
  </code></pre>
  
  <p>to this:</p>
  
  <pre><code>~ # # #
  ~ ~ # ~
  ~ ~ # ~
  ~ ~ ~ ~
  </code></pre>
  
  <p>obviously it will be done in a for loop like my other methods, below i will post the method i have done already for horizontal and rotate clockwise to prove its not homework i cant do</p>
  
  <pre><code>void mirrorHorizontally()
  {
      char[][]horizontalImage = new char[height][width];
  
      for (int i = 0; i &lt; height /2; i++)
      { 
         for(int j = 0; j &lt; width; j++)
         {  
             horizontalImage[height - (i+1)][j] = canvasArray[i][j];           
             horizontalImage[i][j] = canvasArray[height - (i+1)][j];
         }
      }   
      printPicture(horizontalImage);
  }
  
  
  void rotateClockwise()
  {
      char[][] rotatedImage = new char[height][width];
  
      for(int i=0; i&lt; canvasArray.length; i++)
      {
          for(int j= canvasArray.length-1; j &gt;= 0; j--)
          {
              rotatedImage[i][rotatedImage.length-1-j] = canvasArray[j][i]; 
          }
      }
  
      printPicture(rotatedImage);
  }
  </code></pre>
  
  <p>canvasArray is the original image out of interest in a char[][] class variable</p>