First, two discalmers. One, I believe I have an old version of the book, so possibility that it was already fixed exists (although I didn't see this in errata on the website). And second, this really doesn't affect understanding of the material, but might confuse some people who will go through the code line by line (or I just might have wrong understanding).
Let me give you the whole code for the context:
As you can see, each number has tabulation added after it and in the provided output the last 7 is shifted a bit like it was affected by 12 before it
5 2 1 3
3 9 7 9
5 7 12 7
But my understanding of how tabulation works is that 7 should be aligned with rest of numbers in its column and the output should be like this
5 2 1 3
3 9 7 9
5 7 12 7
I tried it on JShell on Ubuntu Focal/bash and it worked first time. I don't think there is a problem with the code. Please give us more details about your terminal/command line.Why are you mixing an ordinary for loop and a for‑each loop?
That's not my code, it's an example from the book. In my terminal it works without dis-alignment as well. Screenshot from the book in attachment.
Sorry for not being clear enough that the output is taken from the book too.
Added to errata. Conveniently the extra space is not in the Java 11 edition of this books. So it did get corrected in our editing process the second book around!