What are Boolean literals in Java?

Java 8Object Oriented ProgrammingProgramming

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
raja
Published on 10-Jan-2018 05:55:44
Advertisements