Java Code Annotation Specification detailed _java

Source: Internet
Author: User

Code with annotations is very important for program developers, with the development of technology, in the project development process, the programmer must be required to write code comments, so that the code to facilitate the subsequent preparation and use.

Basic requirements:

1. Unified annotation Form

Throughout your application, you construct annotations using styles that have consistent punctuation and structure. If you find in other projects that their annotation specifications are different from this document, write the code in accordance with this specification and do not attempt to introduce new specifications into the established specification system.

2. Accurate and concise annotation content

Content to be simple, clear, accurate meaning, to prevent the ambiguity of the annotation, wrong annotation not only useless but harmful.

3. Basic annotation (must be added)

(a) Notes for Class (interface)
(b) Comments on constructors
(c) Comments on the method
(d) Comments on global variables
(e) Note for Field/property
Note: Simple code to do a simple annotation, the annotation content is not greater than 10 words, in addition, the persistent object or
The getter and setter methods of the Vo object need not be annotated. For specific annotation formats, refer to the examples below.

4. Special notes (must be added)

(a) A typical algorithm must have a comment.
(b) There must be a note in the code that is not clear.
(c) Add a comment that modifies the identity at the code modification point.
(d) Annotate in code composed of loops and logical branches.
(e) The interfaces provided to others must be annotated in detail.

Note: This type of annotation format is not an example. The specific annotation format is defined by itself and requires accurate and concise annotation content.

5. Annotation format:

1), single line (single-line) Note: "//..."
2), blocks (block) Note: "/*......*/"
3), Documentation comments: "/**......*/"
4), Javadoc annotation tag syntax

@author the description of the class indicates the author who developed the class module
@version the description of the class indicates the version of the class module
@see references to classes, attributes, and methods, which are related topics
@param description of the method for a parameter in the method
@return description of the method to return the value of the method
@exception the description of the method to the exception that the method might throw

6. Example:

/** 
establishes a tool class for manipulating arrays, which contains functions of this common array of operations: the maximum value. 
@author John 
@version v. 
/Public 
class arraytool{ 

/** 
Gets the maximum value of the shaping array 
@param arr receives an array of type int of an element 
@return the largest element value of the array 
* /Public 
int Getmax (int arr) { 
int Max =; 
return Max; 
} 

Enter the command as shown below:

Then look in the directory below, and then click index.html:


The above content for everyone to share the Java Code Annotation specification, I hope to help.

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.