java comments, keywords and identifiers

Usually we need to add text to the source code to explain the code, but these texts are not the syntax of Java code, which will cause compilation errors. At this point we can use annotations to do this!

At compile time, the compiler ignores the presence of annotations as if the annotation content did not exist. Therefore, comments will not cause compilation errors, and at the same time, comments are also convenient for writers and others to read the source code and enhance their understanding of the code.

There are three annotation methods in Java , which are:

1 single-line comment     // comment content 
2 multi-line comments     /* comment content */ 
3 document comments /** comment content */

  The documentation comments are basically the same as the multi-line comments, the only difference is that the documentation comments can use the javadoc.exe command to generate API documentation. We will not explain it here. After you have a certain understanding of the API , you will learn the relevant knowledge of document annotation to generate API documents!

HelloWorld.java

1  /* 
2  * Implementation steps:
 3  * 1. Define a class class
 4  * 2. Write the entry method for program execution, the main main method
 5  * 3. Send the message "HelloWorld!" through the output statement System.out.println() Printed on the console
 6   */ 
7  // Define a class class 
8  class HelloWorld {
 9      // The entry method for writing program execution, the main main method 
10      public  static  void main(String[] args) {
 11          // Provided by Java The output statement, prints the message "HelloWorld!" on the console 
12          System.out.println("HelloWorld!" );
 13      }
 14 }

It is recommended that everyone write ideas, analysis, and steps when writing code in the future, and then write code. The ideas, analysis, and steps are all placed in the source code using comments.

1.1  Keywords

Keywords are words with special meaning and special purpose given by the Java language . You can first understand Java keywords as "commands"! The keywords in Java are all lowercase. The following are all the keywords in Java . You don't need to memorize them. Important keywords will continue to come out in future learning.
  

 

You can try to see which are the keywords in the HelloWorld case and which are not!

1.2  Identifiers

After learning keywords, let's learn what identifiers are. In fact, in Java programs, except for keywords, they are basically identifiers.

In fact, the identifier is the meaning of the name, and all the names are collectively referred to as the identifier. In Java , classes, methods, and variables are often defined (you will learn them later), and when you define them, you always give them names. These names are identifiers.

What we are going to learn here is how to come up with a name. You may say that you need to learn the name? The answer is of course to learn! What we need to learn is the specification of identifiers.

1  Composition element
 2      English characters: a-zA- Z
 3      Numbers: 0-9
 4      Symbols: _ and $
 5  
6  Identifier rules
 7      Numbers cannot begin with
 8      Key words cannot be used
 9      Strict case sensitivity, no length limit when naming , as far as possible to achieve awareness

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325112382&siteId=291194637