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

 Live Demo

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.

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 26-Jun-2020

522 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements