14.9. The if Statement
The if
statement allows conditional execution of a statement or a conditional choice of two statements, executing one or the other but not both.
IfThenStatement: if (
Expression )
StatementIfThenElseStatement: if (
Expression )
StatementNoShortIf else
StatementIfThenElseStatementNoShortIf: if (
Expression )
StatementNoShortIf else
StatementNoShortIf
The Expression must have type boolean
or Boolean
, or a compile-time error occurs.
14.9.1. The if-then Statement
An if-then
statement is executed by first evaluating the Expression. If the result is of type Boolean
, it is subject to unboxing conversion (§5.1.8).
If evaluation of the Expression or the subsequent unboxing conversion (if any) completes abruptly for some ...
Get The Java® Language Specification, Java SE 7 Edition, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.