title: Java - Printing 2D array like a table - with borders
body: <p>So I need to print a 2D Array like a table, and I have the numbers right, I just can't grasp the concept of printing borders for the table.</p>
  
  <p>Here's what I have</p>
  
  <pre><code>0 0 0 0
  0 0 0 0
  0 0 0 0
  0 0 0 0
  </code></pre>
  
  <p>And I would like it like this, including four character spaces in each box (so it can accommodate numbers in the 1000s) and the numbers aligned right.</p>
  
  <pre><code>---------------------
  |   0|   0|   0|   0|
  ---------------------
  |   0|   0|   0|   0|
  ---------------------
  |   0|   0|   0|   0|
  ---------------------
  |   0|   0|   0|   0|
  ---------------------
  </code></pre>
  
  <p>I don't need any corner borders (for example, a +), only the vertical lines (|) and dashes (-)</p>
  
  <p>How would this be possible?</p>
  
  <p>My code to print my array right now is this:</p>
  
  <pre><code>int [][] gameboard = new int[4][4];
      for(int i = 0; i &lt; gameboard.length; i++)
      {
          for(int j = 0; j &lt; gameboard[i].length; j++)
          {
              System.out.print(gameboard[i][j]);
              if(j &lt; gameboard[i].length - 1) System.out.print(" ");
          }
          System.out.println();
      }
  </code></pre>