Java Boolean Data Types
Very often in programming, you will need a data type that can only have one of two values, like:
- YES / NO
- ON / OFF
- TRUE / FALSE
For this, Java has a
boolean data type, which can only take the values
boolean isJavaFun = true; boolean isFishTasty = false; System.out.println(isJavaFun); // Outputs true System.out.println(isFishTasty); // Outputs false
Boolean values are mostly used for conditional testing.
You will learn much more about booleans and conditions later in this tutorial.