- 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 Literals in Java
The Boolean literals have two values i.e. True and False.
The following is an example to display Boolean Literals.
Example
public class Demo { public static void main(String[] args) { System.out.println("Boolean Literals"); boolean one = true; System.out.println(one); one = false; System.out.println(one); } }
Output
Boolean Literals true false
In the above program, we have declared a boolean value and assigned the boolean literal “true”.
boolean one = true;
In the same way, we have added another boolean literal “false”.
one = false;
Both of the above values are displayed, which are the boolean literals.
- Related Articles
- What are Boolean literals in Java?
- What are Boolean Literals in C++?
- Literals in Java programming
- What are literals in Java?
- What is the difference between character literals and string literals in Java?
- Using underscore in Numeric Literals in Java
- Boolean Type 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
- Define integer literals as octal values in Java
- Java Program to convert boolean value to Boolean
- String representation of Boolean in Java
- Integer literals vs Floating point literals in C#

Advertisements