BLOCKS AND STATEMENTS
The
throw
 Statement
14.16
A
return
 statement with an
Expression
 attempts to transfer control to the
invoker of the method that contains it; the value of the
Expression
 becomes the
value of the method invocation. More precisely, execution of such a
return
 state 
ment first evaluates the
Expression
. If the evaluation of the
Expression
 completes
abruptly for some reason, then the
return
 statement completes abruptly for that
reason. If evaluation of the
Expression
 completes normally, producing a value
V
,
then the
return
 statement completes abruptly, the reason being a
return
 with
value
V
.
It can be seen, then, that a
return
 statement always completes abruptly.
The preceding descriptions say  attempts to transfer control  rather than just
 transfers control  because if there are any
try
 statements ( 14.18) within the
method or constructor whose
try
 blocks contain the
return
 statement, then any
finally
 clauses of those
try
 statements will be executed, in order, innermost to
outermost, before control is transferred to the invoker of the method or construc 
tor. Abrupt completion of a
finally
 clause can disrupt the transfer of control ini 
tiated by a
return
 statement.
14.16   The
throw
 Statement
A
throw
 statement causes an exception ( 11) to be thrown. The result is an imme 
diate transfer of control ( 11.3) that may exit multiple statements and multiple
constructor, static and field initializer evaluations, and method invocations until a
try
 statement ( 14.18) is found that catches the thrown value. If no such
try
statement is found, then execution of the thread ( 17,  20.20) that executed the
throw
 is terminated ( 11.3) after invocation of the
UncaughtException
 method
( 20.21.31) for the thread group to which the thread belongs.
ThrowStatement:
throw
Expression
 ;
The
Expression
 in a throw statement must denote a variable or value of a ref 
erence type which is assignable ( 5.2) to the type
Throwable
, or a compile time
error occurs. Moreover, at least one of the following three conditions must be true,
or a compile time error occurs:
The exception is not a checked exception ( 11.2) specifically, one of the fol 
lowing situations is true:
N
The type of the
Expression
 is the class
RuntimeException
 or a subclass of
RuntimeException
.
N
The type of the
Expression
 is the class
Error
 or a subclass of
Error
.
287






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

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