Eclipse usage and technique 8: automatically add try/Catch Block 1

Source: Internet
Author: User

From the compiler perspective, exceptions in Java can be divided into two types: checked exceptions and unchecked exceptions. For checked exceptions such as IO operations, the compiler requires that you set the try/catch statement block. In eclipse, you only need to use the help shortcut Ctrl + 1 to automatically generate try/catchCode. For unchecked exceptions, the compiler does not require you to add protection blocks, and the IDE help shortcut does not work. Powerful eclipse also provides us with the ability to automatically generate try/catch.
Step 1: select the code that requires try/catch protection, pay attention to the complete line, and right-click:


Step 2: Select surround with and then select try/Catch Block:

Step 3: complete:

Note that the selected code should be in the unit of an entire statement on the Code. Generally, one row is a statement, so we have to select one line above.

 

PreviousArticle, Eclipse usage and tips 7: automatically generate get and Set Method 2:

Http://blog.csdn.net/ts1122/article/details/8893263

In the next article, eclipse usage and technique 9: automatically add try/Catch Block 2:
Http://blog.csdn.net/ts1122/article/details/8933196

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.