title: How to format text correctly using printf() (Java)
body: <p>Hello I want to print something so they are aligned.  </p>
  
  <pre><code>    for (int i = 0; i &lt; temp.size(); i++) {
          //creatureT += "[" + temp.get(i).getCreatureType() + "]";
          creatureS = "\t" + temp.get(i).getName();
          creatureT = " [" + temp.get(i).getCreatureType() + "]";
          System.out.printf(creatureS + "%15a",creatureT + "\n");
     }
  </code></pre>
  
  <p>and the output is</p>
  
  <pre><code>    Lily      [Animal]
      Mary         [NPC]
      Peter      [Animal]
      Squash          [PC]
  </code></pre>
  
  <p>I just want the [Animal], [NPC], and [PC] to be aligned like</p>
  
  <pre><code>    Lily      [Animal]
      Mary      [NPC]
      Peter     [Animal]
      Squash    [PC]
  </code></pre>
  
  <p>Say I know that no name will be greater then 15 characters. </p>