Specifications
if
if ( expression1 ) {
// statements1
} else {
// elsestatements
}
if ( expression1 ) {
// statements1
} else if ( expression2 ) {
// statements2
}
// else if ...
} else {
// elsestatementsN
}
An if statement provides a two-way branch. A multi-way branch is achieved using else ifs. (See
also Switch.)
If the first expression, expression1, is true, then the statements governed by that expression
(statements1) will be executed, after which control will pass to the statement following the if
block.
If expression1 is false, control passes to the else statement. If the else has no following if, the
else statements (elsestatements) are executed, after which control will pass to the statement
following the if block. If the else has a following if, then step 1 or step 2 (this step) is repeated
for that if statement depending on whether its expression is true or false.
finally
try {
Statements;
}
finally {
finalStatements;
}
A "finally" block is a block of code that is executed after the governing try block. If no exceptions
occur within the try block, control will pass to the finally block after the last statement in the
try block has been executed. If an exception occurs within the try block, control is passed
immediately to the finally block.
See try...finally for an example.
label
labelname: Statement;
Statements may be labelled; the syntax is labelname followed by a colon, followed by the
Statement. The labelname is any valid (unique) identifier.
See break for an example.
return
return optExpression;
A return statement may occur anywhere within a function, including member functions, but not
within constructors. When a return statement is encountered, control leaves the function
immediately and execution resumes at the statement following the call that invoked the function.
404
Enfocus Switch 10