title: Formatting Matrix with Labels
body: <p>Ok so this is probably a very basic question but I for the life of me cannot figure out Java output formatting, I just haven't had any practice with it. I am constructing a Term Document Matrix that counts the occurrences of certain words within a series of sentences. The matrix comes out fine with the following code </p>
  
  <pre><code>for(int i=0; i&lt;rows; i++){
              for(int j=0; j&lt;columns; j++){
                  System.out.print(String.format("%3s", matrix[i][j]));
              }
              System.out.println("");
  }
  </code></pre>
  
  <p>Outputting this: </p>
  
  <pre><code>  0  0  1  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  1  0  1  0  1  0  0  1  0  0  1  0  0  0
    0  0  0  0  0  0  1  0  0  0  0  2  0  0  1  0  0  0  0  1  0  2  0  0  0  1  0  0  0  0  0  0  0
    0  0  0  0  1  1  0  0  0  1  1  0  0  0  0  1  0  1  0  0  0  0  0  0  3  0  0  1  0  0  0  0  0
    0  1  0  0  0  0  0  1  0  0  0  0  0  0  1  0  0  0  0  1  0  0  0  1  0  0  0  0  1  0  0  0  0
    0  0  0  0  0  1  0  0  0  0  1  0  0  0  0  0  0  1  0  0  0  0  0  0  2  0  0  0  0  0  0  0  0
    0  0  0  0  0  0  1  1  0  0  0  0  0  0  1  0  0  0  0  1  0  1  0  0  0  0  0  0  0  1  0  0  0
    0  1  1  0  0  0  0  0  0  0  0  2  0  0  1  0  1  0  0  1  0  2  0  0  0  0  1  0  0  0  0  0  0
    1  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  1
    0  0  0  0  1  1  0  0  0  0  1  0  1  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0
    0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0
    0  0  1  0  0  0  1  0  1  0  0  0  0  0  1  0  0  0  0  0  0  0  0  1  0  0  0  0  1  0  0  0  0
    0  0  0  0  0  2  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  2  0  0  3  0  0  0  0  0
    0  0  1  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  1  1  0  0  0  0  0  0  0  0  0  0  0  0
    0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  2  2  0  0
    0  0  1  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0  0
    0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  2  1  1  0  0  0  0  1  0  0  0  0  0  0
    0  0  0  0  1  1  0  0  0  0  1  0  0  0  0  0  0  0  0  0  0  0  0  0  1  0  0  0  0  0  0  0  0
    1  0  0  0  0  0  0  0  0  1  0  0  1  0  0  2  0  0  0  0  0  0  0  0  0  0  0  0  0  1  1  0  0
    0  1  0  1  0  0  1  0  0  0  0  1  0  0  0  0  1  0  0  2  0  1  0  1  0  1  0  0  0  0  0  0  0
    0  0  0  0  1  1  0  0  0  2  0  0  1  1  0  1  0  0  0  0  0  0  0  0  3  0  0  0  0  0  0  0  1
  </code></pre>
  
  <p>However I would like to add row and column identifiers so that it looks more like this (The column Headers come from a string Array and there would be 20 sentences):</p>
  
  <pre><code>             applianc, around, autonom, averag, bath, bedroom, car, charg, drive, eat, home, hour, hous, includ, kilomet, kitchen, lap, larg, live, mile, over, per, pet, road, room, second, sedan, size, test, up, updat, veri, water
  Sentence 1:
  
  Sentence 2:
  
  Sentence 3:
  .
  .
  .
  </code></pre>
  
  <p>With the rows and columns lining up so that they are easily identifiable, perhaps with grid or something as seperators. I am clueless as to how to make this happen.</p>