• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Boolean wrapper class

 
preeti khane
Ranch Hand
Posts: 93
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1090
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1392
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the code from Boolean.java (1.4.1)
 
pinky yadav
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
false
true
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic