Formatted output is accomplished using a format string and one or more arguments. Inside the format string are format specifiers which indicate which aregument to substitute, what kind of conversion is required for the value, and the format in which it should be printed. The format specifiers are in the form of:
%[argument_index$][flags][width][.precision]conversion
Note that the parts of the specifier inside of the square braces [] are optional. That implies that the minimal format specifier is the % symbol and the conversion character, such as %f to print a floating point value or %d to print an integer value.
The argument_index# portion of the specifier tells the compiler which argument from the argument list should be inserted into the specifier's location in the String. For example, 3$ would say take the third argument, 1$ says take the 1st argument. This enables you to print the same value in more than one way in the same format String.
The flags portion is conversion specific but controls format attributes such as justification and the printing of negative and separator symbols.
The width portion tells the compiler how many positions the corresponding value should take in the String. For numeric values, this is a minimum; values exceeding this minimum will print all significant digits.
The .precision portion specifies the number of decimals to the right of the decimal point for a double value.
For further details about each of the specifier components, please review the Java API's for format strings found here. Go to the String class, the format method, and the format string link.