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