This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes printf() method clarification required Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "printf() method clarification required" Watch "printf() method clarification required" New topic

printf() method clarification required

M Kothawade

Joined: Dec 29, 2008
Posts: 9
System.out.printf("%d", 12.3);
throws exception.

System.out.printf("%b", 12.3); doesn't throw any exception.
Punit Singh
Ranch Hand

Joined: Oct 16, 2008
Posts: 952
%b and %s will never throw exception in these types of case.

for %b if you pass null, boolean false or Boolean false then it will print false, otherwise for any values it will print true.

M Kothawade

Joined: Dec 29, 2008
Posts: 9
I went through and got the same answer.

Thanks once again.
I agree. Here's the link:
subject: printf() method clarification required
It's not a secret anymore!