14.20. The try statement

A try statement executes a block. If a value is thrown and the try statement has one or more catch clauses that can catch it, then control will be transferred to the first such catch clause. If the try statement has a finally clause, then another block of code is executed, no matter whether the try block completes normally or abruptly, and no matter whether a catch clause is first given control.

TryStatement:    try Block Catches    try Block Catchesopt Finally    TryWithResourcesStatementCatches:    CatchClause    Catches CatchClauseCatchClause:    catch ( CatchFormalParameter ) BlockCatchFormalParameter:    VariableModifiersopt CatchType VariableDeclaratorIdCatchType:    ClassType    ClassType | CatchTypeFinally:     ...

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.