Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

convert string to boolean java

boolean boolAnswer;
//answer represents the string you want to convert to boolean
String answer;
answer = "yes";

//compares given variable (answer) to defined true value (yes).
boolAnswer = answer.equals("yes"); //boolAnswer is true

answer = "no" //or anything that isn't "yes", including null
boolAnswer = answer.equals("yes") //boolAnswer is false
Source by www.tutorialspoint.com #
 
PREVIOUS NEXT
Tagged: #convert #string #boolean #java
ADD COMMENT
Topic
Name
7+7 =