Privacy Policy Terms Of Use. Copyright © 2006-2010 Java Tutorials and Examples.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
- /*
- * Convert String to Boolean example. Program to convert Java
- * String object to Boolean object.
- */
- public class StringToBoolean {
- public static void main(String args[]){
- //new String object
- String str = new String("true");
- //Use Boolean(String) constructor
- Boolean bObj1 = new Boolean(str);
- //OR Use static valueOf(String) method of Boolean class
- Boolean bObj2 = Boolean.valueOf(str);
- System.out.println("String converted to Boolean: " + bObj1);
- }
- }

Post new comment