File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Boolean wrapper class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Boolean wrapper class" Watch "Boolean wrapper class" New topic

Boolean wrapper class

preeti khane
Ranch Hand

Joined: Mar 12, 2003
Posts: 93
Could someone explain , when the Boolean wrapper class equates to true / false when comparing 2 objects... I have seen that this class acts different compared to the other wrapper classes... and has some similarity with the String class (in terms of the true/false literals)
Anupam Sinha
Ranch Hand

Joined: Apr 13, 2003
Posts: 1090
Boolan objects if created by passing in a String will be true if the String passed is true(in any case). So True, TrUe, tRuE, TRUE and any other combination of cases in the same order will cause the Boolean object to contain true. Any other value will cause the wrapper to contain false. When toString is used then however the value that will be printed will be however true or false(in lowercase). Consider this :

Hope that helps.
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
Here is the code from (1.4.1)
pinky yadav
Ranch Hand

Joined: Jun 17, 2002
Posts: 44
one more point the static valueOf(boolean) and valueOf(String) method return reference to the static Boolean object in the class Boolean.
thus the following code gives the output as:
I agree. Here's the link:
subject: Boolean wrapper class
It's not a secret anymore!