How to remove leading/trailing white spaces from a line of integers?
<p>I have to print out the table in a matrix like fashion, each number formatted to a width of 4 (The numbers are right-aligned and strip out leading/trailing spaces on each line). The first 3 line will look like:</p>

<pre><code>1   2   3   4   5   6   7   8   9  10  11  12
2   4   6   8  10  12  14  16  18  20  22  24
3   6   9  12  15  18  21  24  27  30  33  36
</code></pre>

<p>This is my code:</p>

<pre><code>public static void main (String[] args) {
    int i,j;
    for(i=1;i&lt;=3;i++){
        for(j=1;j&lt;=12;j++){
            System.out.format("%4d",i*j);
        }
        System.out.println();
    }
}   
</code></pre>

<p>In the output the first integer gets shifted by 3 spaces.How to strip out the leading/trailing spaces on each line?  </p>