Java Boolean

Java Boolean Data Types  are a primitive data type. It is used to store only two possible values, either true or false.

Boolean values are mostly used for conditional testing.
 

Example

boolean b1 = true;

boolean b2 = false;

System.out.println(b1);     // Outputs true
System.out.println(b2);   // Outputs false

 

 

 

Example :

public class Aryatechno {
public static void main(String[] args) {
boolean b1, b2;
System.out.println("Boolean Type in Java");
b1 = true;
if(b1)
System.out.println("This is true.");
b2 = false;
if(b2)
System.out.println("This is false.");
}
}

Output :

Boolean Type in Java
This is true.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

36941