Académique Documents
Professionnel Documents
Culture Documents
SYNTAX
Format_String is a string including one format specifier for each Output argument.
Format_String is output with each format specifier replaced by its corresponding Output
APPENDIX
argument in the format given by the Output arguments format specifier.
s String. %12s
%s
c Character. %2c
%c
A number of the form N.M in a format specifier specifies a field width of N spaces
with M digits after the decimal point. If only one number N is given, it specifies a field
width, and if there is a decimal point in the output, then the number of digits after the
decimal point is determined by Java.
1128 APPENDIX 4 Format Specifications for printf
When the value output does not fill the field width specified, then blanks are added
in front of the value output. The output is then said to be right justified. If you add a
hyphen (-) after the %, then any extra blank space is placed after the value output and
the output is said to be left justified. For example, %8.2f is right justified and %-8.2f is
left justified.