java-Keywords & identifiers

Source: Internet
Author: User

Key words:

keywords are identifiers that have special meanings in Java programs. Keywords are typically used to describe the structure of a program or to represent a data type. They are used to represent a data type , or to represent the structure of a program , etc., and the keyword cannot be used as a variable name, method name, class name, package name.

1.1 Common keywords

Note: you do not have to memorize, if you use the keyword as an identifier, the compiler can prompt for errors.

Goto is a reserved keyword for Java, meaning that Java does not use Goto and is later used undecided.

Identifier:

Some of the names in Java programs can be customized, so these custom names are called as custom identifiers.

Identifiers to note the details:
1. The constituent element of the identifier is the letter (a-za-z), the number (0-9), the underscore (_), the dollar sign ($).
2. Identifiers cannot begin with a number.
3. Identifiers are strictly case-sensitive.
4. The length of the identifier is not limited in length.
5. The name of the identifier is generally meaningful (to make people aware of the name, to improve the code of reading)
6. Keywords, reserved words cannot be used for custom identifiers.

Specification for custom identifiers:
1. The first letter of the class name and interface list Word is capitalized, and the other words are lowercase. For example: RunTime.
2. Variable name and method name the first word all lowercase, other words first uppercase, other lowercase. For example: Docook ();
3. Package name all words lowercase.
4. Constant all the words are capitalized, and the words are separated from the words using an underscore. For example: up_direction

Legal identifiers

Computearea,radius,area $itcast, _itcast,gz_itcast

Note: Because Java is strictly case-sensitive, itcast and itcast are completely different identifiers

Illegal identifiers

    1. Class (keyword)
    2. 100java (cannot start with a number)
    3. Hello Java (spaces are not elements that make up identifiers)

Identifier Case:
12ABC_//illegal numbers cannot start
_12ABC//Legal
$ab 12#//illegal #号不属于标识符组成元素.
[Email protected]//Illegal @ does not belong to the identifier component element.

java-Keywords & identifiers

Related Article

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.