- 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
Java Program to convert an Integer to a boolean specifying the conversion values
To convert an Integer to a boolean, we have taken the following Integer objects.
Integer one = 1; Integer two = 1; Integer three = 0;
We have taken nested if-else statement to display the true or false values. Here, the value “one” is the same as “two” i.e. 1; therefore, the following else-if works.
else if (one.equals(two)) { System.out.println(true); }
The above display “true” and in this way we converted Integer to boolean.
Let us now see the complete example to learn how to convert an Integer to Boolean.
Example
public class Demo { public static void main(String[] args) { Integer one = 1; Integer two = 1; Integer three = 0; // Integer to Boolean if (one == null) { if (two == null) { System.out.println(true); } else if (three == null) { System.out.println(false); } } else if (one.equals(two)) { System.out.println(true); } else if (one.equals(three)) { System.out.println(false); } } }
Output
True
- Related Articles
- Java Program to convert an int to a boolean specifying the conversion values
- Java Program to convert integer to boolean
- Java Program to convert boolean to integer
- Java Program to convert boolean value to Boolean
- Java Program to convert String to Boolean
- Java Program to convert Boolean to String
- Java Program to convert an integer into binary
- How to convert a Boolean to Integer in JavaScript?
- Java Program to convert integer to octal
- Java Program to convert integer to hexadecimal
- Convert Java Boolean Primitive to Boolean object
- Java Program to convert from integer to String
- Java Program to convert from String to integer
- C# Program to convert a Double to an Integer Value
- Program to convert set of Integer to Array of Integer in Java

Advertisements