Eclipse usage and technique 9: automatically add try/Catch Block 2

Source: Internet
Author: User
Tags finally block

The previous article introduced how to quickly add try/catch statements for non-checked exceptions. Here we will add some other related operations. Sometimes we need to add a Finally block after adding a try/catch. For example, we recommend that you add a Finally block at the end of the Code for every allocation of a cursor on Android, and disable cursor to prevent memory leakage. The total memory usage of cursor on Android is 2 MB. If the high-frequency method of the app does not close cursor in time, it will cause other modules to fail to allocate cursor. Next we will introduce how to add quick operations for finally blocks.

Step 1: based on the previous article, add the try/catch statement and place the cursor in the try line:

Step 2: press Ctrl + 1 to add the Finally block:

 

Finally, add some other things: place the cursor on the line of the try statement, press Ctrl + 1 to add a Finally block, and place the cursor on the line of catch, press Ctrl + 1 to delete the try/catch statement. These operations also work for adding for and while loop blocks. You can try them yourself.

 

In the previous article, eclipse usage and technique 8: automatically add try/Catch Block 1:
Http://blog.csdn.net/ts1122/article/details/8886219
Next article, eclipse usage and tips 10: Show Code outline:

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

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.