Originally Posted by
helloworld922
Please don't post "hijack" someone else's post please
Start a new topic if you have a separate un-related question.
Also, make sure you use [highlight] tags around your code, they make it much easier to read it. If you're unsure how to do this, see my signature.
It's not aligning because you're printing out some 2-digit numbers, which take up more space than 1-digit numbers.
To manually fix this, you can calculate how many spaces to print out based on the number of digits you're printing out. There are also "automatic formatters" built into Java, but they're a little more difficult to use.
Ok next time i'll start a new thread. Could you elaborate more about the "automatic formatters"?
Originally Posted by
Norm
Using tab characters gives you left alignment. Ie the first character of each string will be in the same column. I don't know why your output doesn't show that. When I run your code I get:
0 1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10 11
2 3 4 5 6 7 8 9 10 11 12
3 4 5 6 7 8 9 10 11 12 13
4 5 6 7 8 9 10 11 12 13 14
5 6 7 8 9 10 11 12 13 14 15
6 7 8 9 10 11 12 13 14 15 16
7 8 9 10 11 12 13 14 15 16 17
8 9 10 11 12 13 14 15 16 17 18
9 10 11 12 13 14 15 16 17 18 19
10 11 12 13 14 15 16 17 18 19 20
Notice that all the first digits are in column.
Thanks for your info though