How convert string object to boolean object using wrapper class

How convert string object to boolean object using wrapper class

Previous Home Next

 

This example shows the conversion of string object to Boolean object.

This is a simple program which is used to convert string object to the Boolean object. valueOf() method is used here to convert string object to Boolean object.
 valueOf() is used to convert the string to the Boolean.


 

package Example;

public class StringtoBoolean {


public static void main(String[] args) {
String str = "True"; // string object is constructed
Boolean obj = new Boolean (str);
System.out.println(obj);
Boolean obj2 = Boolean.valueOf(str);
System.out.println(obj2);



}

}

true
true

Previous Home Next