title: Print Java arrays in columns
body: <p>I'm trying to format two arrays in Java to print something like this:</p>
  
  <pre><code>Inventory Number      Books                          Prices
  ------------------------------------------------------------------
  1                     Intro to Java                  $45.99
  2                     Intro to C++                   $89.34
  3                     Design Patterns                $100.00
  4                     Perl                           $25.00
  </code></pre>
  
  <p>I am using the following code:</p>
  
  <pre><code>for(int i = 0; i &lt; 4; i++) {
          System.out.print(i+1);
          System.out.print("                     " + books[i] + " ");
          System.out.print("                 " + "$" + booksPrices[i] + " ");
          System.out.print("\n");
      }
  </code></pre>
  
  <p>But I am getting this poorly formatted result instead:</p>
  
  <pre><code>Inventory Number      Books                          Prices
  ------------------------------------------------------------------
  1                     Intro to Java                  $45.99 
  2                     Intro to C++                  $89.34 
  3                     Design Patterns                  $100.0 
  4                     Perl                  $25.0 
  </code></pre>
  
  <p>How would I go about lining all the columns up directly under the headers at the top?</p>
  
  <p>Is there a better way to go about doing this?</p>