Java Reference
In-Depth Information
The conditional expressions are evaluated from the top downward. As soon as a true con-
dition is found, the statement associated with it is executed, and the rest of the ladder is
bypassed. If none of the conditions are true, the final
else
statement will be executed. The
final
else
often acts as a default condition; that is, if all other conditional tests fail, the last
else
statement is performed. If there is no final
else
and all other conditions are false, no
action will take place.
The following program demonstrates the
if-else-if
ladder: