English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Java Program to Convert String to Boolean

To convert String to Boolean, please useparseBoolean()A method in Java. InparseBoolean()Parse the string parameter as a boolean value. If the string parameter is not null and equals case-insensitively to the string "true", then the returned boolean value represents true.

First, declare a string.

String str = "false";

Now, use the Boolean.parseBoolean() method to convert the above declared String to Boolean.

boolean bool = Boolean.parseBoolean(str);

Now let's see the complete example to learn how to convert String to Boolean.

Example

public class Demo {
   public static void main(String[] args) {
      //String
     String str = "false";
      //String to boolean
      boolean bool = Boolean.parseBoolean(str);
      //The returned boolean value
      System.out.println(bool);
   }
}

Output Result

false