Eclipse Code Templates build quickly

Source: Internet
Author: User

In our development process, some code is often repeated and is necessary, such as singleton mode, observer mode.

Repeat and repeat every time.

So how do we improve our efficiency?

Keep in mind that we are using the IDE, not a text editor. Use the tools and do more!

Let's write some of this today. How to quickly write a code template for a single sample. Then make up the observer and other ... The parameters are then described individually.

Click Windows-preferences-java-editor-templates in 1.Eclipse to go to the specific Settings page.

2. Click New to open the template window

3. Enter this template name in the name input box, which is named: Instance

4. In description Add a description of the template (not required), the personal side is filled with: non-thread-safe single case

5. Add the template code to the pattern, the following is a singleton

Private Static ${enclosing_type} sinstance; Private ${enclosing_type} () {}  Public Static ${enclosing_type} getinstance () {    ifnull) {        new  $ {Enclosing_type} ();    }     return sinstance;}

Note: Enclosing_type represents the class name

OK, configure the above template. The next use is simple!

1. Create a new class.

2. Press alt+/in the class and select instance.

0 seconds to write a single case!

More efficient development, waiting for everyone to explore together!

Eclipse Code Templates build quickly

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.