Java programming those things 20-blank, statement end and notes Zhengzhou game college Chen yuefeng from: http://blog.csdn.net/mailbomb
3.8 BlankIn the previous section, we have introduced that in code writing, spaces must be used to separate words and words. There is no limit on the number of spaces. In actual coding, in order to make the code structure clear, a certain number of spaces need to be added before the code, such as the following format: public class blank {public static void main (string [] ARGs) {int N; {n = 10;} system. out. println (n) ;}} in this Code, each line contains a certain number of spaces except the first and last lines. This encoding format is called code indent. In actual code, the code should be indented as long as there is a inclusion relationship, and the statement block is one of the most typical inclusion relationships. Note: during compilation, spaces at the beginning of each line are ignored.
3.9 statement endedIn Java syntax, the statement uses ";" as the row Terminator, for example, int n = 2. Generally, only one sentence is written per line in the code, however, you can also write multiple sentences, for example, int n = 2; byte B = 10; but to make the code structure clear, you can write only one sentence in one line. Sometimes the Code itself is long, you can also write a sentence of code in multiple lines, and write a ";" at the end of the Code statement. In actual code, the beginning and end of braces and the end of most parentheses do not need to be written.
3.10 annotationsComment is a description of the functions and usage of the Code. Compiling appropriate comments in the program will make the program code easier to read and enhance the maintainability of the Code. Annotations are ignored during program compilation, so Annotations do not increase the size of the class file. In Java, there are three types of syntax for annotation: single line annotation, multi-line annotation, and document annotation.
3.10.1 single line commentA single-row comment is a comment that can only be written in one row. A single-line comment is the simplest syntax format in the comment. It is used to briefly describe the code, such as the variable function. The syntax format of a single line comment is: // The comment content starts with two diagonal lines. The subsequent content of the line is the comment content, and the comment content cannot be wrapped. A single-line comment is generally written in the previous line of the Code to be explained, or at the end of the code line. The example structure is as follows: // The cyclic variable int I = 0; char sex; // gender
3.10.2 multi-line commentMulti-line comment refers to the comment that can be written in any number of rows. Multi-line comments are generally used to describe complex content, such as program logic or Algorithm Implementation Principles. The syntax format of Multiline comments is:/* comments */Comments start with a slash and an asterisk, followed by comments. Comments can be written in any number of lines, the comment ends with an asterisk and a diagonal line. Many Lines of Comments start with a star in each line. This is not required by syntax.
3.10.3 document commentDocument annotation refers to the annotation format that can be extracted to form a program document, which is a special annotation format in Java. The structure of a program is generally described, such as classes, attributes, methods, and constructor. These concepts will be described in detail later. The syntax format of the document comment is/** comment content */The comment starts with a slash and two asterisks, followed by the comment content. The comment content can be written in any number of lines, the comment ends with an asterisk and a diagonal line. The syntax format of the comment will be improved in the subsequent content.
3.10.4 othersIn standard code, there are usually 10%-20% comments, that is, every 100 lines of code contains 10-20 lines of comments, but many domestic development companies are far below this requirement. In addition, in actual project development, after modifying the code, you must modify the content of the comment to keep the code and the comment synchronized.