Originally posted by adam Lui: can anyone explain this line
does it read as "we take this Long object, convert it and use it as a String.
Kinda. The Long isn't "converted" in the sense of widening or auto-boxing. Rather, the formatter just invokes its toString() method.
if it has the promote mechanism, why does not work?
Because "%d" is for integers, but you're providing a double value. You need an explicit cast to make that work.
The format specifiers can be a bit confusing if you don't have a C programming background. "%d" doesn't stand for "double", but for "decimal (i.e. base 10) integer", as opposed to "%o" for octal integer and "%x" for hexadecimal integer. To format a double value, most of the time you'd use "%f" (for floating-point number, which in Java would be either a float or double).
If you're interested in the full details, take a look at the Formatter javadoc. For the SCJP exam, you just have to know the format string specifiers mentioned in K&B.