14.18.2
Execution of
try catch finally
BLOCKS AND STATEMENTS
N
If the run time type of
V
 is not assignable to the parameter of any
catch
clause of the
try
 statement, then the
try
 statement completes abruptly
because of a
throw
 of the value
V
.
If execution of the
try
 block completes abruptly for any other reason, then
the
try
 statement completes abruptly for the same reason.
In the example:
class BlewIt extends Exception {
BlewIt() { }
BlewIt(String s) { super(s); }
}
class Test {
static void blowUp() throws BlewIt { throw new BlewIt(); }
public static void main(String[] args) {
try {
blowUp();
} catch (RuntimeException r) {
System.out.println("RuntimeException:" + r);
} catch (BlewIt b) {
System.out.println("BlewIt");
}
}
}
the exception
BlewIt
 is thrown by the method
blowUp
. The
try
catch
 statement
in the body of
main
 has two
catch
 clauses. The run time type of the exception is
BlewIt
 which is not assignable to a variable of type
RuntimeException
, but is
assignable to a variable of type
BlewIt
, so the output of the example is:
BlewIt
14.18.2   Execution of
try catch finally
After the great captains and engineers have accomplish'd their work,
After the noble inventors after the scientists, the chemist,
the geologist, ethnologist,
Finally shall come the Poet . . .
 Walt Whitman,
Passage to India
 (1870)
292






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