Boolean Datatype Example Java Program

Definition

The boolean data type has only two possible values: true and false. Use this data type for simple flags that track true/false conditions. This data type represents one bit of information.

Syntax

boolean varibale_name = true/false;

Syntax Example

boolean gear = true;

Boolean Datatype Example Program

 
class BooleanDatatype{
	public static void main(String[] args){
		boolean b=(10>9)?true:false;
		System.out.println("10>9 is "+b);
	}
}

Sample Output

Output is:
10>9 is true