This is the third day of my participation in the August Text Challenge.More challenges in August

Hello everyone, I’m Bob, a developer who focuses on software and the bottom layer of computer

Java, is now the computer professional is undoubtedly the easiest language to find a job, the use of people is also very many, the top three languages will generally have Java.

So, let’s start with Java’s coding specifications, such as commonly used identifiers and keywords and comments.

Identifiers

First of all, learning Java requires understanding some of its file structures, which we’ll cover next time. Let’s start with its identifiers. In simple terms, identifiers are sequences of characters used to name classes, interfaces, methods, variables, and so on.

Some rules about using identifiers in programming: 1. Letters, digits, underscores (_), and $.

2. Do not start with a number.

3. Do not use the Java keyword.

4. Case sensitive.

To: When using variables, utF-8 supports Chinese, so it is possible To use Chinese variables, but the editor does not recommend using Chinese variables, if the encoding is different, it may actually cause problems.

Character sequences include classes, interfaces, methods, and variables.

(1) Classes, interfaces, and naming rules: Uppercase single word and other lowercase words for example: Hello Multiple words: uppercase the first letter of each word and lowercase words for example: HelloWorld

(2) Variable and method naming rules: single word: all lowercase letters Example: check() Multiple words: all lowercase letters, all uppercase letters Example: checkUserName()

(3) Common naming rules: Single word: uppercase letters Example: NUMBER Multiple words: uppercase letters separated by underscores Example: MAX_VALUE

To: Do not start a variable with a number.

Source code comments

Huawei’s standard for comments is that at least 30% of the code in source programs should be annotated, and the content of comments should be clear and accurate. Indirectly explain the importance of comments when typing code.

So there are three types of comments in Java: single-line comments: //

Multi-line comments: /* */

Document comment: /** */(document comment Javadoc generated document)

Documentation comments, which add some information to the source code through commands, will be covered next time you use Eclipse.

In essence, annotation means that when the compiler compiles a program, if it finds annotated content, it will not compile the part. There are three types of annotations in Java: class annotations, multi-line annotations, and single-line annotations.

Iii. Summary of relevant rules

Finally, about the layout rules and naming rules of the program:

Layout rules:

1. The program block adopts the indent rule, the indent space is four, the TAP indent is not allowed.

2. Delimiters (such as braces {} on each line) should be left aligned with the statement that quotes them.

3. Separate long statements, expressions, or parameters (>=80 characters) into multiple lines.

4. Do not put multiple phrases in one line, that is, write only one statement in one line, and leave one line blank after defining variables.

5. Statements such as if for do while case switch default occupy one line respectively.

6. If for do while, etc., the execution part of the statement should be parentheses no matter how much.

Naming rules:

1. Complete English description of class name and interface name: Use uppercase for the first letter of each English word, and use lowercase combination for other letters.

2. Complete English description of method names: use lowercase letters for the first word and uppercase letters for the rest of the word.

3. Attribute names are described in full English: use lowercase letters for the first word and uppercase letters for the rest of the word.

4. Constant names are described in all uppercase English: language words are separated by underscores and static final modifier is used.