Java annotations, keywords, and identifiers

Source: Internet
Author: User
Tags java keywords

usually we need to add text in the source code to explain the code, but the text is not The syntax of the Java code can cause compilation errors. At this point we can use the comments to complete this matter!

At compile time, the compiler ignores the presence of annotations as if the comment content does not exist. So annotations do not cause compilation errors, and annotations make it easier for the writer and others to read the source code and to enhance the understanding of the code.

There are three types of annotations available in Java, namely:

1 Single-line comment    // Comment content 2 Multiline comment/    * Comment Contents */3 /** Comment Content */

where a document comment is basically the same as a multiline comment, the only difference is that the document comment can use the Javadoc.exe command to generate the API documentation. Here we do not explain it, and so you have a certain understanding of the API in the learning document comments generated API documentation related knowledge!

Helloworld.java

1 /*2 * Implementation steps:3 * 1. Define a class of classes4 * 2. Write the entry method of program execution, main Main method5 * 3. The message "helloworld!" via the output statement System.out.println () Print on the console6  */7 //define a class of classes8 classHelloWorld {9     //write the entry method of the program execution, main Main methodTen      Public Static voidMain (string[] args) { One         //using the output statement provided by Java, the information "helloworld!" Print on the console ASystem.out.println ("helloworld!"); -     } -}

We recommend that you write your ideas, analysis, steps, and then write code when you write your code. The ideas, the analysis, the steps are all in the source code using comments.

1.1 Key Words

keyword is The Java language gives special meanings to words that have specialized uses, such as the class,public,static, void is already pre-programmed for Java. You can first understand the Java keyword as "command"!
  Java keywords are lowercase, the following is All the keywords in Java, you do not need to go back, in the future learning important keywords will continue to come out.

you can try to see What are keywords in the HelloWorld case, and which are not!

1.2 identifiers

After learning the keyword, let's learn what an identifier is. In fact , in the Java program, in addition to the keyword is basically an identifier.

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

Here we have to learn how to name, you may say the name still need to learn? The answer is, of course, to learn! What we want to learn is the specification of identifiers.

1 constituent elements 2     English characters: a-za-Z3     number: 0-94     Symbol: _ With $56 identifier rule  7     digits cannot begin with 8 cannot     use keyword 9 to be     strictly case-sensitive, Do not limit the length of the naming, as far as possible to achieve the name of understanding

Java annotations, keywords, and identifiers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.