How convert boolean object to string object

How convert boolean object to string object

Previous Home Next

 

This Example shows how to convert the Boolean object to the String object.

Using toString() method of Boolean class we will convert the Boolean object to the String Object.
 toString() method of Boolean class convert the boolean object to the string object.

First construct Boolean object obj. and then use toString () method to convert it to the string.

 

package Example;

public class Boleantostring {


public static void main(String[] args) {
Boolean obj=new Boolean("true");
String str =obj.toString();
System.out.println(str);

}

}

true

Previous Home Next