Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-30-2007, 06:46 AM   PM User | #1
prajwala
New Coder

 
Join Date: Feb 2007
Posts: 67
Thanks: 7
Thanked 0 Times in 0 Posts
prajwala is an unknown quantity at this point
Question How to convert string to boolean

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 ,
prajwala is offline   Reply With Quote
Old 08-30-2007, 12:37 PM   PM User | #2
ess
Regular Coder

 
Join Date: Oct 2006
Location: United Kingdom
Posts: 865
Thanks: 7
Thanked 29 Times in 28 Posts
ess will become famous soon enough
here is an example of converting from strings to boolean values

Code:
String val = "true";
boolean ok = Boolean.parseBoolean(val) ;
Cheers,
Ess
ess is offline   Reply With Quote
Old 08-30-2007, 04:03 PM   PM User | #3
shyam
Senior Coder

 
shyam's Avatar
 
Join Date: Jul 2005
Posts: 1,563
Thanks: 2
Thanked 163 Times in 160 Posts
shyam will become famous soon enough
pls note parseBoolean is available only in java5 for prev versions u have to go through this
Code:
boolean ok = Boolean.valueOf(val).booleanValue();
__________________
You never have to change anything you got up in the middle of the night to write. -- Saul Bellow
shyam is offline   Reply With Quote
Old 09-05-2007, 07:07 AM   PM User | #4
prajwala
New Coder

 
Join Date: Feb 2007
Posts: 67
Thanks: 7
Thanked 0 Times in 0 Posts
prajwala is an unknown quantity at this point
Thanks
prajwala is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:21 PM.


Advertisement
Log in to turn off these ads.