In Java, how do I use print or printf to have A line of text, that has the first output as "Character Name:" (which is aligned to the left by default) and then show a string value (char1) to be aligned to the right of the screen, or aligned to the right of a column? ie:
Character Name: char1
Character Value: charValue
ps. I am using eclipse if that helps.
You will have to mess around with the formatting to decide how many spaces you'll have to include in between; it will depend on the length of the left justified word. But using a format
%s
will right justify by default, or left justify if you use%-s
. The number between%
&s
is the amount of spaces in between.