title: How to format an array of integers in java
body: <p>Currently I have the following method:</p>
  
  <pre><code>public static void printDoubleIntArray(int[][] doubleIntArray) {
  for (int x = 0; x &lt; doubleIntArray.length; x++) {
      System.out.println();
      for (int y = 0; y &lt; doubleIntArray[x].length; y++) {
      System.out.print(doubleIntArray[x][y]);
      }
  }
  }
  </code></pre>
  
  <p>It works perfectly when the parameter "doubleIntArray" is only numbers from 0 - 9 like in the following print out:</p>
  
  <pre><code>0000000
  0000300
  0033332
  0023323
  0022223
  0023233
  0003332
  </code></pre>
  
  <p>However, if the integers in each element of the array become larger than 9 then I get something like the following: </p>
  
  <pre><code>0000000
  000121797
  001717171716
  0101617171617
  001616161617
  081617161717
  001417171716
  </code></pre>
  
  <p>What I would like to know is how do I make the above example print out like so:</p>
  
  <pre><code>0   0   0   0   0   0   0
  0   0   0  12  17   9   7
  0   0  17  17  17  17  16
  0  10  16  17  17  16  17
  0   0  16  16  16  16  17
  0   8  16  17  16  17  17
  0   0  14  17  17  17  16
  </code></pre>