The string, identical to fmt, except that each format specifier occurring in fmt is replaced by the converted string value of its corresponding argument.
The fmt parameter is a string that contains zero or more
characters as well as the following format specifiers (a.k.a, "conversions"):
%c a character with the given number
%s a string
%d a signed integer, in decimal
%i a synonym for %d
%o a octal integer
%x a hexadecimal integer
Non-standard format specifiers:
%b a boolean value
%C a character, enclosed in single quotation marks
%S a string, enclosed in double-quotation marks
%O like %o, but with a "0" prefix for non-zero values
%X like %x, but with a "0x" prefix for non-zero values
%e a floating-point number, in scientific notation
%f a floating-point number, in fixed decimal notation
Flags between the % and the conversion letters e or f):
number digits after decimal point for floating-point
(NOTE: Use with s or d or i won't be supported)
Use %% for a single percent sign (%) in the fmt string.
String.format() is intended for producing message strings that are useful for debugging, logging, or displaying output to the user. To permit this, format specifiers exist such as %b and %S that are well-suited for these purposes. Consequently, there is no attempt to adhere to, nor implement all of, the format specifiers found in sprintf() and related C library functions printf(), fprintf(), etc.
String.format() is a class method. It is not necessary to
invoke it on a String instance.