Java and java annotations
Note
What is annotation? It is the meaning of annotation explanation, which is mainly used to describe Java code. There are three ways to comment in Java (1): //: comment a single line statement
Example:
// Define an int variable int a = 10;
(2):/**/: multi-line comment
Example :/*
This is a comment and will not be used by Java to run it. This is the second line of comment. There can be any number of lines */
(3):/***/: Document comment
A document comment placed before the declaration of variables, methods, or classes indicates that the comment should be placed in an automatically generated document (an HTML file generated by the javadoc command) as a description of the declared item.
Example :/**
* This is a document annotation test.
* It generates standard java interface documents through javadoc */
A tag starting with "@" is often added to javadoc comments. Combined with the javadoc command parameters, a specific tag can be generated in the generated API documentation.
What are single-line and multi-line annotations in JAVA? I don't understand. Can I explain it? For example,
A comment is a simple description and cannot be executed as an execution statement. As a programmer, we write the code along the train of thought. Writing code is like doing the problem. When you are doing this, your mind is clear and you will think of some special methods to solve the current problem. But when you solve a large problem. There are a lot of ideas and some are complicated. Now, when you write code, you know why you want to write it. But a few days or months later, when you open your code again. You will find that a lot of code is confusing. I will forget the functions or implementation process of some of the code I wrote at that time. Simply put, we will forget our ideas at that time.
At this time, the comment function is very important. When you are writing code. You can write down some instructions (comments) to explain your ideas or the functions and functions of the Code. With these instructions, you can quickly retrieve your current ideas and quickly understand the code when looking back at your previous code in a few months. It is worth mentioning. In the future, it will often be teamwork. Today, you have written several codes. You may ask for leave tomorrow, and another person will take over your job. Then write your code. But if you use some ideas that others don't know when writing code. Without comments, it is hard for others to understand your code. It's hard to take over your job.
The above is just to make the landlord understand the importance of the comment. Okay. The following is a positive answer to the author's question:
As mentioned above. The code can be annotated to illustrate the role of the code you have written. In Java, there are single-line comments, multi-line comments, and document comments.
(1) single line comment: Start with "//" followed by the description to be added. As shown below:
// Define variable
Int a = 10;
// Define variable B
Int B = 20;
In the preceding statement, the comments are skipped during the compilation process, and only the int a = 10 and int B = 20 sentences are compiled. It can be seen that annotations only play a role in illustration.
(2) multi-line comment: starts with "/*" and ends.
Suppose you want to describe the functions of your code. There are many content to explain. It would be ugly to put them all in the same row. Therefore, it is generally written in multiple rows, as shown below:
// Description
// Description
// Description
// Description
The preceding four line annotations are used to comment out the four line descriptions. However, if there are 10 lines of description, it is very troublesome to press 10 "//". Therefore, you can use multiple lines of comment. The above can be changed:
/*
Description
Description
Description
Description
*/
You can also
/* Description
Description
Description
Description */
(3) document notes: Start with "/**" and end. Document comments mainly generate documents. I just learned Java and may not know what API documentation is. Therefore, I will not explain it here. You will understand it later.
That's all. Hope to help the landlord, I wish the landlord a pleasant learning! O (∩) O Haha ~
Comments before java method names
After the method is completed, enter "/**" in the method and press Enter.
However, you need to modify the description of parameters and returned values.