aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Printf Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Printf" Watch "Printf" New topic
Author

Printf

Srinivas Katta
Ranch Hand

Joined: Feb 01, 2007
Posts: 76
Can anybody explain the below , I have gone through printf specifications but the below statement is confusing for me



Thanks
Srinivas
lakmal padmakumara
Ranch Hand

Joined: Aug 08, 2009
Posts: 47
I think the problem you have is with the "true" part which is get printed.When you try to convert something in to boolean if it is false it returns false .Any other occurrences returns true value .So here second argument 654 is convert to a boolean value and returns a true .I suggest you to read the printf and Formatter API . And K&B have good examples on these matters.


[Bsc in Computer Science and Engineering] [SCJP 80%][BCS certificate level]
Srinivas Katta
Ranch Hand

Joined: Feb 01, 2007
Posts: 76
Thanks for the Clarification, But I have the similar code using teh formatter class as given below


it prints the output as true false but I am expecting it to be false false
lakmal padmakumara
Ranch Hand

Joined: Aug 08, 2009
Posts: 47
This is the exact thing I explained earlier .You can pass a string value to Boolean constructor and it doesn't check for Case sensitiveness. Whether you pass TRuE TRUE or true it makes a boolean Wrapper object of true value.

printf only returns false if you convert a boolean false value to a boolean.Here what you pass is a String object ("FAlse").Whether you change it to "false" it still returns true, until you pass a boolean false value .

check this code
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Printf