Java error: line scroll

I want to align the number in a string as follows:

3 x  89 kg
3 x 133 kg

I use this format:

String.format("%1$3d x %2$3d kg", nb, weight);

But the result is incorrect:

enter image description here

+4
source share
1 answer

This is due to the font (because the characters do not have the same width). Change the font to a monospace font and the problem will be solved (I recommend Console for this)

+1
source

Source: https://habr.com/ru/post/1607076/


All Articles