BLOCKS AND STATEMENTS
Execution of
try catch
14.18.1
parameter
); the declared type of the exception parameter must be the class
Throwable
or a subclass of
Throwable
, or a compile time error occurs. The
scope of the parameter variable is the
Block
of the
catch
clause. An exception
parameter must not have the same name as a local variable or parameter in whose
scope it is declared, or a compile time error occurs.
The scope of the name of an exception parameter is the
Block
of the
catch
clause. The name of the parameter may not be redeclared as a local variable or
exception parameter within the
Block
of the
catch
clause; that is, hiding the name
of an exception parameter is not permitted.
Exception parameters cannot be referred to using qualified names ( 6.6), only
by simple names.
Exception handlers are considered in left to right order: the earliest possible
catch
clause accepts the exception, receiving as its actual argument the thrown
exception object.
A
finally
clause ensures that the
finally
block is executed after the
try
block and any
catch
block that might be executed, no matter how control leaves
the
try
block or
catch
block.
Handling of the
finally
block is rather complex, so the two cases of a
try
statement with and without a
finally
block are described separately.
14.18.1 Execution of
try catch
Our supreme task is the resumption of our onward, normal way.
Warren G. Harding, Inaugural Address (1921)
A
try
statement without a
finally
block is executed by first executing the
try
block. Then there is a choice:
If execution of the
try
block completes normally, then no further action is
taken and the
try
statement completes normally.
If execution of the
try
block completes abruptly because of a
throw
of a
value
V
, then there is a choice:
N
If the run time type of
V
is assignable ( 5.2) to the
Parameter
of any
catch
clause of the
try
statement, then the first (leftmost) such
catch
clause is
selected. The value
V
is assigned to the parameter of the selected
catch
clause, and the
Block
of that
catch
clause is executed. If that block com
pletes normally, then the
try
statement completes normally; if that block
completes abruptly for any reason, then the
try
statement completes
abruptly for the same reason.
291
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