 
 Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert Java String Object to Boolean Object
A string object can be created in Java using the string literal.
String myStr = “Amit”;
Another way to create a string object is using the new keyword.
String myStr = new String("Hello!");
We have used the first method to create a string object.
String str = "true";
Now, use the valueOf() method to convert String Object to Boolean Object. We have used this method on Boolean object.
Boolean bool = Boolean.valueOf(str);
Let us now see the complete example to show how to convert String Object to Boolean Object.
Example
public class Demo {
   public static void main(String[] args) {
      String str = "true";
      // conversion
      Boolean bool = Boolean.valueOf(str);
      System.out.println(bool);
   }
}
Output
True
Advertisements
                    