Java Program to convert boolean variables into string

To understand this example, you should have the knowledge of the following Java programming topics:


Example 1: Convert boolean to string using valueOf()

In the above example, we have used the valueOf() method of String class to convert the boolean variables into strings.


Example 2: Convert boolean to String using toString()

We can also convert the boolean variables into strings using the toString() method of the Boolean class. For example,

In the above example, the toString() method of Boolean class converts the boolean variables into strings. Here, Boolean is a wrapper class. To learn more, visit the Java Wrapper Class.