title: How to print Strings in aligned columns in Java?
body: <p>I hava a question on the printing Strings. The program should do the following job:
  get a String as parameter and identify the words and prints them in three columns aligned:
  Example:</p>
  
  <pre><code>the quick brown fox jumped over the lazy dog
  </code></pre>
  
  <p>and output should be:</p>
  
  <pre><code>the  quick   brown
  fox  jumped  over
  the  lazy    dog
  </code></pre>
  
  <p>My solution was</p>
  
  <pre><code>private void printColumn(String s){
  StringTokenizer toker = new StringTokenizer(s);
  while (toker.hasMoreTokens()){
      String temp = "";
      for (int i = 0; i &lt; 3; i++){
    temp +=toker.nextToken();
  }
      System.out.print(temp);
  System.out.println();
  }
  }
  </code></pre>
  
  <p>but my output is not aligned</p>
  
  <pre><code>the  quick  brown
  fox  jumped  over
  the  lazy  dog
  </code></pre>
  
  <p>any advice please?</p>