- Trending Categories
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
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
- Related Articles
- Convert Java Boolean Primitive to Boolean object
- Parse a string to a Boolean object in Java
- Java Program to convert Java String to Float Object
- Java Program to convert String to Boolean
- Java Program to convert Boolean to String
- Convert string of time to time object in Java
- Create a Boolean object from Boolean value in Java
- how to convert Object array to String array in java
- How to convert InputStream object to a String in Java?
- Convert the number or boolean type JSON object from string type to its original in JavaScript
- Golang Program to Convert String to Object
- Convert a string to hierarchical object - JavaScript
- How to convert a String to an InputStream object in Java?\n
- Convert JSON object to Java object using Gson library in Java?\n
- How to convert OpenCV Mat object to BufferedImage object using Java?

Advertisements