Java Reference
In-Depth Information
The output generated by this program is shown here:
There are three interesting things to notice about this program. First, as you can see,
when a
boolean
value is 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 like this:
Third, the outcome of a relational operator, such as
<
, is a
boolean
value. This is why the
expression
10 > 9
displays the value "true." Further, the extra set of parentheses around
10
> 9
is necessary because the
+
operator has a higher precedence than the
>
.