Generating a Try-Catch Block

See Also

In the Source Editor, you can quickly generate code for try-catch blocks or convert existing blocks into try-catch blocks.

To generate a try-catch block from a code template, do one of the following things in the Source Editor:

A try-catch block is generated. Your insertion point is left resting on the word Exception. You can then type in the exception that you want use.

To surround an existing group of statements with a try block:

  1. Select a block of code in the Source Editor.
  2. Choose Source > Surround With try-catch (Alt-Shift-W).

    A try block is created for code. If the IDE detects any uncaught exceptions, a catch block is inserted for each uncaught exception. If there are no exceptions, a finally block is inserted.

See Also
Completing a Java Expression
Inserting Code From a Template
Using the Word Match Feature

Legal Notices