- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to convert String to Boolean
To convert String to Boolean, use the parseBoolean() method in Java. The parseBoolean() parses the string argument as a boolean. The boolean returned represents the value true if the string argument is not null and is equal, ignoring case, to the string "true".
Firstly, 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);
Let us now 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); // returned boolean value System.out.println(bool); } }
Output
false
Advertisements