Java Boolean Keyword
Java has a primitive type, called boolean, for logical values. It can have only one of two possible values, true or false.
Output - Sample output would be -
There are three interesting things to notice about this program. First, as you can see, when a boolean value is an output by println( ), “true” or “false” is displayed. Second, the value of a boolean variable is sufficient, by itself, to control the if statement. There is no need to write an if statement this way -
if(b == true)
Third, the outcome of a relational operator, such as <, is a boolean value. This is why the expression 14 > 11 displays the value “true.” Further, the extra set of parentheses around 14 > 11 is necessary because the + operator has higher precedence than the >.