- 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 boolean value to Boolean
Use the valueOf() method to convert boolean value to Boolean. Firstly, let us take a boolean value.
boolean val = false;
Now, to convert it to Boolean object, use the valueOf() method.
Boolean res = Boolean.valueOf(val);
Let us now see the complete example to convert boolean value to Boolean.
Example
public class Demo { public static void main(String[] args) { boolean val = false; System.out.println("Boolean Value = "+val); Boolean res = Boolean.valueOf(val); System.out.println("Boolean = " + res); if (res.equals(Boolean.TRUE)) { System.out.println("Boolean = " + res); } else { System.out.println("Boolean = " + res); } } }
Output
Boolean Value = false Boolean = false Boolean = false
Advertisements