| Author |
printf() doubt
|
sweety singh
Ranch Hand
Joined: Dec 15, 2007
Posts: 49
|
|
code: int i1 = -123; int i2 = 12345; System.out.printf(">%1$(7d< \n", i1); //1 System.out.printf(">%0,7d< \n", i2); //2 System.out.format(">%+-7d< \n", i2); //3 System.out.printf(">%2$b + 1$5d< \n", i1, false); This produces: > (123)< >012,345< >+12345 < >false + -123< // line 2 produces the output >012,345<... how is the comma arranged after three digits.. is it by default... it is not mentioned in the format string also... and why is line 3 using format method... is it that printf and format can be used interchangeablly [ February 07, 2008: Message edited by: sweety singh ] [ February 07, 2008: Message edited by: sweety singh ] [ February 07, 2008: Message edited by: sweety singh ]
|
 |
Murali Kakarla
Ranch Hand
Joined: Jul 11, 2007
Posts: 80
|
|
In Page 490 of Bert and Kathy book:
"," Use locale-specific grouping separators....
In Page 489:
The format() and printf() methods were added to java.io.PrintStream in Java 5. These two methods behave exactly the same way, .....
I think this clears your questions. Murali...
|
 |
 |
|
|
subject: printf() doubt
|
|
|