A boolean type is declared with the boolean
keyword and can only take the values true
or false
:
Example
boolean isJavaFun = true;
boolean isFishTasty = false;
System.out.println(isJavaFun); // Outputs true
System.out.println(isFishTasty); // Outputs false
However, it is more common to return boolean values from boolean expressions, for conditional testing (see below).
Practice Excercise Practice now