BLOCKS AND STATEMENTS
The
if then else
Statement
14.8.2
14.8 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
)
Statement
IfThenElseStatement:
if (
Expression
)
StatementNoShortIf
else
Statement
IfThenElseStatementNoShortIf:
if (
Expression
)
StatementNoShortIf
else
StatementNoShortIf
The
Expression
must have type
boolean
, or a compile time error occurs.
14.8.1 The
if then
Statement
I took an early opportunity of testing that statement . . .
Agatha Christie,
The Mysterious Affair at Styles
(1920), Chapter 12
An
if
then
statement is executed by first evaluating the
Expression
. If evaluation
of the
Expression
completes abruptly for some reason, the
if
then
statement
completes abruptly for the same reason. Otherwise, execution continues by mak
ing a choice based on the resulting value:
If the value is
true
, then the contained
Statement
is executed; the
if
then
statement completes normally only if execution of the
Statement
completes
normally.
If the value is
false
, no further action is taken and the
if
then
statement
completes normally.
14.8.2 The
if then else
Statement
An
if
then
else
statement is executed by first evaluating the
Expression
. If
evaluation of the
Expression
completes abruptly for some reason, then the
if
then
else
statement completes abruptly for the same reason. Otherwise, execu
tion continues by making a choice based on the resulting value:
273
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved