14.18. The throw Statement
A throw
statement causes an exception (§11) to be thrown. The result is an immediate transfer of control (§11.3) that may exit multiple statements and multiple constructor, instance initializer, static initializer and field initializer evaluations, and method invocations until a try
statement (§14.20) is found that catches the thrown value. If no such try
statement is found, then execution of the thread (§17) that executed the throw
is terminated (§11.3) after invocation of the uncaughtException
method for the thread group to which the thread belongs.
ThrowStatement: throw
Expression ;
The Expression in a throw
statement must denote either 1) a variable or value of a reference type which is assignable (§5.2) to the ...
Get The Java® Language Specification, Java SE 7 Edition, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.