14.1
Normal and Abrupt Completion of Statements
BLOCKS AND STATEMENTS
14.1 Normal and Abrupt Completion of Statements
Poirot's abrupt departure had intrigued us all greatly.
Agatha Christie,
The Mysterious Affair at Styles
(1920), Chapter 12
Every statement has a normal mode of execution in which certain computational
steps are carried out. The following sections describe the normal mode of execu
tion for each kind of statement. If all the steps are carried out as described, with no
indication of abrupt completion, the statement is said to
complete normally
. How
ever, certain events may prevent a statement from completing normally:
The
break
( 14.13),
continue
( 14.14), and
return
( 14.15) statements
cause a transfer of control that may prevent normal completion of statements
that contain them.
Evaluation of certain Java expressions may throw exceptions from the Java
Virtual Machine; these expressions are summarized in 15.5. An explicit
throw
( 14.16) statement also results in an exception. An exception causes a
transfer of control that may prevent normal completion of statements.
If such an event occurs, then execution of one or more statements may be ter
minated before all steps of their normal mode of execution have completed; such
statements are said to
complete abruptly
. An abrupt completion always has an
associated
reason
, which is one of the following:
A
break
with no label
A
break
with a given label
A
continue
with no label
A
continue
with a given label
A
return
with no value
A
return
with a given value
A
throw
with a given value, including exceptions thrown by the Java Virtual
Machine
The terms complete normally and complete abruptly also apply to the
evaluation of expressions ( 15.5). The only reason an expression can complete
abruptly is that an exception is thrown, because of either a
throw
with a given
value ( 14.16) or a run time exception or error ( 11, 15.5).
264
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