Boolean Datatype in Java

Boolean Datatype: Boolean is simple Java type which can have only of two values;
1.true
2.false.

Default value of boolean is false

All rational expressions return this type of value
.
Syntax Declare boolean variable as below
   boolean <variable name> = <default value>;

Note:
Here assigning default value is optional.

public class Boolean {
 
        public static void main(String[] args) {
 
                boolean b1 = true;
                boolean b2 = false;
                boolean b3 = (13> 2)? true:false;
               
                System.out.println("Value of boolean variable b1 is :" + b1);
                System.out.println("Value of boolean variable b2 is :" + b2);
                System.out.println("Value of boolean variable b3 is :" + b3);            
        }
}
 


Output:
Value of boolean variable b1 is : true
Value of boolean variable b2 is : false
Value of boolean variable b3 is : true