import java.util.Scanner;
public class ConvertStringToBoolean
{
public static void main(String[] args)
{
// create object of scanner.
Scanner KB=new Scanner(System.in);
// enter path here.
System.out.print("Enter the string here : ");
//construct String object
String str =KB.next();
// Convert using constructor
Boolean blnObj1 = new Boolean(str);
System.out.println("Boolean value is : " +blnObj1);
}
}
Output
First run:
Enter the string here : true
Boolean value is : true
Second run:
Enter the string here : false
Boolean value is : false
Program to convert string to Boolean in java
Output
need an explanation for this answer? contact us directly to get an explanation for this answer