title: How to format string output, so that columns are evenly centered?
body: <p>In my java class we wrote a card program in which you choose a "secret card", and at the end it tells you what your secret card was. I am only having one issue, and that is formatting the output. As of right now, when it prints the fist column is even but the 2nd and 3rd are not. My teacher said to use spaces, but I have tried this and does not work. I know there is a way to format it but am unsure. The output looks like this:</p>
  
  <pre><code>     Column 0           Column 1           Column 2
      ________________________________________________
       3 of Spades    3 of Diamonds  Ace of Diamonds
       9 of Diamonds    2 of Diamonds   10 of Diamonds
     Ace of Spades   10 of Hearts King of Clubs
       6 of Clubs    4 of SpadesQueen of Hearts
       5 of Diamonds    2 of Hearts    7 of Clubs
       2 of Spades Jack of Diamonds    3 of Hearts
       5 of Hearts    4 of Hearts    7 of Diamonds
  </code></pre>
  
  <p>My output code is as follows:</p>
  
  <pre><code>import java.util.Scanner;
  import java.util.Random;
  
  public class CardTrick {
    public static void main(String[] args) {
  
  /* declare and initialize variables */
  int column = 0, i = 0;
  String name = " ";
  String playAgain = " ";
  String seeDeck = " ";
  
  /* Declare a 52 element array of cards */
  Card[] deck = new Card[52];
  
  /* Declare a 7 by 3 array to receive the cards dealt to play the trick */
  Card [][] play = new Card[7][3];
  
  /* Declare a Scanner object for input */
  Scanner input = new Scanner(System.in);
  </code></pre>
  
  <p>If you want I can post the entire code, but I was trying not to post a lot. I greatly appreciate any help, being I am new to Java.</p>