- 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
Boolean Type in Java
To display Boolean type, firstly take two variables and declare them as boolean.
boolean val1, val2;
Then one by one assign values to both of them, one of them is shown below −
val1 = true;
Now, use if statement to check and display the Boolean true value.
if(val1) System.out.println("This is true and will get displayed!");
Let us now see the complete example to work with Boolean Type in Java.
Example
public class Demo { public static void main(String[] args) { boolean val1, val2; System.out.println("Boolean Type in Java"); val1 = true; if(val1) System.out.println("This is true and will get displayed!"); val2 = false; if(val2) System.out.println("This is false and won't get displayed!"); } }
Output
Boolean Type in Java This is true and will get displayed!
- Related Articles
- How to check if String value is Boolean type in java?
- PHP Boolean Data Type
- Using real Boolean type in SAP ABAP
- Boolean Literals in Java
- Create a Boolean object from Boolean value in Java
- Convert Java Boolean Primitive to Boolean object
- Java Boolean operators
- Generate Random boolean in Java
- What is the type specifier for boolean in C++?
- Java Program to convert boolean value to Boolean
- What are Boolean literals in Java?
- String representation of Boolean in Java
- C++ Program to Convert String Type Variables into Boolean
- Golang Program to convert string type variables into Boolean
- Swift program to convert string type variable into boolean

Advertisements