Quickly generate notes and adjust formats in eclipse

Source: Internet
Author: User

Eclipse has two very simple functions, but it is absolutely very practical!

1. Annotations are very important. In eclipse, you can quickly generate annotations. Right-click the method body to be annotated and choose-source-gernerate element comment (shortcut keys are also available: alt + Shift + J)

After you click it, the following comments are generated, including the parameter comments used by the method.

When you hover the mouse over a non-method body of the class, a comment will be added to the class. The default author is the login user name and can be modified by yourself, as shown below:

2. Code with a good format is often more readable. Sometimes the code downloaded from the internet is too messy and you can use this method to solve it! It is also valid for XML, and the method is to right-click any location-source-format

Before formatting:

After formatting:

After formatting, you must be in a great mood!


Additional: Sometimes the format function of eclipse will automatically wrap the line, and sometimes the code looks uncomfortable, so I checked the information on the Internet:

1. preferences-> JAVA-> code style-> code formatter-> show...
After opening, select the "line wrapping" tab and wrap the line when "maximun line width" specifies the number of columns that are greater than the limit.
2. on the "line wrapping" tab, you can select "line wrapping policy" to specify line breaks for constructors and method bodies.
However, sun's recommended encoding style defaults to 80-column line breaks.

There is a slight deviation between different versions of eclipse. The following is the interface for my actual operation. It is for reference only: (the system profile cannot be modified. You need to create a new one and change the name, can be changed)I changed it to 500.


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.