Register / Login
File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
Programmer Certification (OCPJP)
printf(String, Object) and format(String, Object) methods
posted 7 years ago
According to K&B book, the format
should be as follows:
[Array index] [Flags] [Width] [.Precision] [Conversion]
And the array index is starting from 1: 1$, 2$ ...
Flags: +, - , 0, , , (
Width: integer number
Conversion: b, c, d, s, f
My question is:
How many flags can be used in combination? I have tried and it seems to m that maximum only 2 flags in be used together.
For example: System.out.printf("%2$(010d*", "Hello", -200);
How does the compiler interpret the format string from left to right? For example: how does it differenciate between flags and width and conversion etc.
I agree. Here's the link:
Printing the index of an array
printf, multiple flags
Regarding printf() method
How to convert old java I/O code to nio ...