File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Programmer Certification (SCJP/OCPJP)
printf(String, Object) and format(String, Object) methods
Joined: Aug 10, 2008
Aug 11, 2008 22:45:00
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:
subject: printf(String, Object) and format(String, Object) methods
Printing the index of an array
printf, multiple flags
Regarding printf() method
How to convert old java I/O code to nio ...
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015