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 ]