| Author |
ExamLab Question - Formatting
|
Richa Sharma
Ranch Hand
Joined: Dec 06, 2008
Posts: 47
|
|
Hi Guys
why does the output includes true in this examlab question?
Thanks
Richa
|
 |
Devaka Cooray
Saloon Keeper
Joined: Jul 29, 2008
Posts: 2691
|
|
Well, try this out:
Can you see the difference?
|
Author of ExamLab (Download) - the free mock exam kit for SCJP / OCPJP
Home Page -- Twitter Profile -- JavaRanch FAQ -- How to Ask a Question
|
 |
Richa Sharma
Ranch Hand
Joined: Dec 06, 2008
Posts: 47
|
|
|
Got It Thanks Deveka
|
 |
S Ali
Ranch Hand
Joined: Aug 23, 2009
Posts: 129
|
|
|
because %b will print true for any non boolean type that is not null.
|
SCJP 6
|
 |
Fritz Guerilus
Ranch Hand
Joined: Jun 20, 2009
Posts: 65
|
|
I thought the answer would be:
07.00settrue
based:
on the flag being 0
and
the width being 2
But I compiled/executed the code and the answer is:
7.00settrue.
My question:
what happened to the flag & width ("%02...") portion of the format specifier?
-Thank You
|
SCJP 6.0
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
|
The %02. portion includes the width of the fractional part too, so it says that the minimum width of the number should be 2 including the part after the decimal point...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
 |
|
|
subject: ExamLab Question - Formatting
|
|
|