
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
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
Parse String to 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.
Advertisements