Convert boolean to String in Java

In some scenarios, we may need to Convert boolean to String in Java. A boolean can be converted to String in java in following ways.

1) Using String.valueOf(boolean b):

The String.valueOf(boolean b) method takes boolean value as an input and returns the String representation of the boolean argument.


b – a boolean.

a string representation of the boolean argument.

2) Using Boolean.toString(boolean b):

This method is same as String.valueOf(boolean b) method and returns a String object representing this Boolean’s value.


b – a Boolean to be converted.

Returns a String object representing the specified Boolean. The argument is converted to signed decimal representation and returned as a string.


Let’s see how to Convert boolean to String with an example. Here we have taken 2 Boolean variables which are to be converted to String.

Let’s see the output of the above program.


The above program demonstrates the boolean to String conversion with an example. You can also learn how to convert int to String in Java at this tutorial Convert int to String in Java.