What are Boolean Literals in Java



Boolean literals represent only two values true or false. And in Java the value of 1 is assumed as true and the value of 0 is assumed as false.

Example

Live Demo

public class Test{
   public static void main(String args[]) throws Exception{
      boolean bool1 = true;
      boolean bool2 = false;
      boolean bool = (25==(100/4));

      System.out.println(bool1);
      System.out.println(bool2);
      System.out.println(bool);
   }
}

Output

true
false
true
Updated on: 2019-07-30T22:30:20+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements