Brief description of 3 annotation methods in Java

Java annotations, there are a total of 3 annotation methods

1. Line comments

Only one line of content can be commented, and it is used in places where the comment information content is small.

The shortcut key in IDEA is: Ctrl + /

Shortcut key Press once to comment, press again to cancel the comment.

// Comment content

 

2. Comment multi-line, block comment

The shortcut key in IDEA is: Ctrl + Shift + /

Shortcut key Press once to comment, press again to cancel the comment.

/*

Note content

Note content

Note content

*/

3. Documentation comments

Included between "/**" and "*/", it can also comment on multiple lines. It is generally used on classes, methods and variables to describe their functions. After commenting, placing the mouse on the class and variable will automatically display the content of our comment.

The shortcut key in IDEA is: /**+Enter.

Shortcut key click annotation. Only this annotated method can be written to the javadoc document

/**

*Note content

*...........

*/

Examples of the above three annotations:

public class Demo {
    /**
     * @param args 这是一个实例
     * @auther 作者名
     * @Date 时间
     */
    public static void main(String[] args) {
        System.out.println("Hello world!"); // 输出Hello world!
        /*
        这是刚开始的代码
         */
    }
}

4. Some descriptions of javadoc comments (document comments) tag syntax.

Some clarifications of javadoc comment tag syntax. (you can enter @, add alt + / (completion key))

@author Author name. Available in: class annotations.

@deprecated Description of a class or method This class or method is not recommended, causing deprecated warnings

@exception A description of the exception that may be thrown. Available in: method annotations.

@note represents annotations, documents exposed to source code readers

Description of the @param parameter. Available in: method annotations.

@return Description of the return value. Available in: method annotations.

@remark indicates comments, documentation exposed to client programmers

@see Generates a hyperlink of "see xx's entry" in the document, which can be followed by: "class name", "full class name", "full class name#method". Available for: class, method, variable annotations.

@since indicates that this function has been available since that version

@version version information. Available in: class annotations.

For more instructions, please refer to: Java Documentation Comments ( java Documentation Comments_java Documentation Comments Label_Western Jin's no1's Blog-CSDN Blog )

5. Precautions

Comments The content of comments should be simple, clear, and accurate in meaning to prevent ambiguity in comments. Wrong comments are not only useless but harmful.

 

Guess you like

Origin blog.csdn.net/xijinno1/article/details/132073837