PDA

View Full Version : How to convert string to boolean


prajwala
08-30-2007, 07:46 AM
If i want to convert string value in boolean then how can i do this?
For example : am passing arguments "true" or "false" into the parameter.According to the value (true/false) user entered, it should show me 0 /1.


Thanks ,

ess
08-30-2007, 01:37 PM
here is an example of converting from strings to boolean values


String val = "true";
boolean ok = Boolean.parseBoolean(val) ;


Cheers,
Ess

shyam
08-30-2007, 05:03 PM
pls note parseBoolean is available only in java5 for prev versions u have to go through this
boolean ok = Boolean.valueOf(val).booleanValue();

prajwala
09-05-2007, 08:07 AM
Thanks :)