Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding String to Boolean

 
surya.raaj prakash
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,



why In preceding code it always gives false even i pass null value?
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the API docs
The boolean returned represents the value true if the string argument is not null and is equal, ignoring case, to the string "true".

As you can see, anything else besides "true", including null generates false.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
surya.raaj prakash wrote:why In preceding code it always gives false even i pass null value?


Because that's how the method works. If you pass anything other than a string containing the value "true" (ignoring case) the method returns false.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic