boolean Datatype in Java

Java Programming Language / DataTypes in java

2409

  • boolean data type represents one bit of information
  • There are only two possible values: true and false
  • This data type is used for simple flags that track true/false conditions
  • Default value is false
  • Example: boolean one = true

Program:

 public class BooleanDataType {

   public static void main(String []args) {
      // this is declaration and initialization of variable a
	  // datatype is boolean
	  boolean a = true;
	  // this is declaration and initialization of variable b
	  // datatype is boolean
      boolean b = false;
      System.out.println(a); // it will print a variable
      System.out.println(b); // it will print b variable

   }
}

  

Output:

true
false
Press any key to continue . . .

Explanation:


This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.