- 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
Parse a string to a Boolean object in Java
The valueOf() method returns the relevant Number Object holding the value of the argument passed. The argument can be a primitive data type, String, Boolean, etc. Therefore, to parse a string to a Boolean object, use the Java valueOf() method.
The following is an example showing how to parse a string to a Boolean object in Java.
Example
public class Demo { public static void main(String[] args) { System.out.println("Parsing a string to a Boolean object..."); Boolean val = Boolean.valueOf("true"); System.out.println("Value: "+val); } }
Output
Parsing a string to a Boolean object... Value: true
Boolean object is used to parse a string in the above program.
Boolean val = Boolean.valueOf("true");
We have passed a string “true” to valueOf() method above. This string is parsed.
- Related Articles
- Convert Java String Object to Boolean Object
- Create a Boolean object from Boolean value in Java
- Convert Java Boolean Primitive to Boolean object
- How to parse a JSON string using Streaming API in Java?
- Java Program to create a boolean variable from string
- How can we parse a nested JSON object in Java?
- How to check that a string is parse-able to a double in java?
- How to parse for words in a string for a specific word in java?
- Parse Octal string to create BigInteger in Java
- Parse decimal string to create BigInteger in Java
- Parse hexadecimal string to create BigInteger in Java
- How to create a Boolean object in JavaScript?
- Java Program to convert String to Boolean
- Java Program to convert Boolean to String
- JavaScript Convert a string to boolean

Advertisements