Recipe 3.11 Surrounding Code with doforiftrywhile Blocks


Recipe 3.11 Surrounding Code with do/for/if/try/while Blocks

3.11.1 Problem

You want to enclose a section of code in a try/catch block or in a do/for/if/while construct.

3.11.2 Solution

Select the lines to surround, press Ctrl-1 (or select Edit Quick Fix) to list all the possibilities, and select one of them.

3.11.3 Discussion

Figure 3-14 shows the possibilities that appear when you select code and press Ctrl-l. When you select one of these possibilities, the selected code becomes surrounded with the construct you've chosen .

Figure 3-14. Surrounding code in a block

One of the great things here is that if you surround your code with a try/catch block in this way, Eclipse automatically figures out all the possible exceptions and catches them for you.

3.11.4 See Also

Chapter 2 of Eclipse (O'Reilly).

Eclipse Cookbook
Inside XML (Inside (New Riders))
ISBN: 596007108
EAN: 2147483647
Year: 2006
Pages: 232
Authors: Steve Holzner

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: