loading

Boolean

Java Boolean Data Types

You will frequently need a data type in programming that can only contain one of two values, such as:

  • YES / NO
  • ON / OFF
  • TRUE / FALSE

Java has a boolean data type for this, which only accepts the values true or false:

Example

				
					boolean isJavaFun = true;
boolean isFishTasty = false;
System.out.println(isJavaFun);     // Outputs true
System.out.println(isFishTasty);   // Outputs false
				
			

Conditional testing mostly makes use of boolean values.

Later on in this course, you will discover a great deal more concerning booleans and conditions.

Share this Doc

Boolean

Or copy link

Explore Topic