In order to form a personal Java code style, when we develop in the project team, we can make some formatting on our own code, as follows:
Method one: Settings in eclipse automatically generate comments when new classes are created
Windows–>preference
Java–>code Style–>code Templates
Code–>new Java Files
Edit it
${filecomment}${package_declaration}/*** @author 作者 E-mail:* @version 创建时间:${date} ${time}* 类说明*/${typecomment}${type_declaration}
Method Two:
Open the parameter Settings panel from the menu window->preference and select:
Java-code Style--code Templates
Select Comments on the right, place the files item, and then choose "Edit" on the right to enter edit mode:
After entering edit mode, you can customize the annotations. You can also insert some variables, such as year, date, and so on.
Finally, make sure that the Code-and New java files have: "${filecomment}"
Of course, with the "Export" and "import" functions, you can export your own templates for use on other machines.
The above is a file comment, and the method in the class automatically adds a comment similar to the types below files.
Eclipse shortcut key: Alt+shift+j after selecting your method
Create annotations automatically when eclipse creates a new Java class