Today, when I was learning JavaScript annotations, what was the difference between comparing Java annotations? The following is a detailed comparison.
Comments for Java
Java is divided into 3 types of annotations when using annotations.
Single-line Comment: Add a symbol "//" before the content of the comment.
Multiline comment: Start with "/*" and End with "*/".
Document Comment: Start with "/**" and End With "*/".
For example:
Package com.zm.test;
/**
* This is a document comment
* @author ZM
*
*/
public class Test {
/*
* This is a multiline comment
* can include multi-line content OH
*/
public static void Main (string[] args) {
This is a single-line comment
System.out.println ("Hello world! ");
System.out.println ("Hello world!");
}
}
PS: commented code blocks are not executed while the program is running, and you can use the Javadoc tag to generate more detailed document information when using document annotations:
@author identify the author of the development of such modules
@version indicate the version of the module
@see reference steering, i.e. related topics
@param a description of a parameter in the method
@return Description of the return value of the method
@exception description of the exceptions that the method might throw
Comments for JavaScript
JavaScript is divided into 2 types of annotations when using annotations.
A single-line comment, with the symbol "//" before the content of the comment. For example:
<script type= "Text/javascript" >
document.write ("single-line comment using '//'"); I am the comment that the statement function outputs content in a Web page
</script>
Multiline comments, starting with "/*" and ending with "*/". For example:
<script type= "Text/javascript" >
document.write ("Multi-line Comment using/* Comment content */"); /* Multiline comments develop a good habit of writing notes * *
</script>
Summarize
From the above comparison, it is obvious that Java has a document comment, while the other 2 kinds of comments: single-line comments, multiline comments are the same as JavaScript.
Comment Differences between Java and JavaScript