Online Java Compiler By
JavaTpoint.com
public class BooleanValueOfExample5 { public static void main(String[] args) { //for "true" (ignoring the case) string value this method will return true. String str = "True"; Boolean b1 = Boolean.valueOf(str); System.out.println("1. Boolean value for "+str+" is "+b1); //for "false" String value this method will return false String str1= "false"; Boolean b2 = Boolean.valueOf(str1); System.out.println("2. Boolean value for "+str1+" is "+b2); //for any String value other than "true" this method will return false. String str2 = "hwhfjh"; Boolean b3 = Boolean.valueOf(str2); System.out.println("3. Boolean value for "+str2+" is "+b3); } }
Output