public class Main {
public static void main(String[] args) {
// create a boolean variable
boolean isTrue = true;
// convert boolean to String using valueOf method
String str = String.valueOf(isTrue);
System.out.println("Boolean value: " + isTrue);
System.out.println("String value: " + str);
}
}
Boolean value: true
String value: trueisTrue and initialize it with the value true.String.valueOf() method. This method takes a boolean value as an argument and returns the string "true" or "false" depending on the value of the boolean.System.out.println() method.