The beginning of the nameless world, the mother of all things----Java identifiers and keywords (3)

Source: Internet
Author: User
Tags float double switch case try catch

Learning language know the most basic is the noun, not only the number of more, the meaning of expression is the most basic. You can not understand the grammar, simply say a few nouns can also express the approximate meaning. If we often meet foreign friends, sometimes it is to say a noun ask the way, we can understand that he is thinking of there. So in Java, a noun-like identifier is also an important syntax. Computer language is different from the real language, the computer language requires precision, precision, which is which, a different letter that is different.

In front of the word identifier is equivalent to a noun in a language, one of the functions of a noun is to give an identity or title to something that exists (for example, apples, air conditioners describe something that exists), and there are many situations in the Java language that require an identity or designation, such as the "HelloWorld" encountered earlier. Called a string, a "string" is a noun used to describe the HelloWorld. Identifiers are used in the Java language when it comes to describing things and naming things. Things in Java are part of Java, such as variables, constants, classes, arrays, methods, objects, and so on. However, the use of identifiers has certain rules, such as the name of a person, to follow certain specific rules.

Identifiers in Java can only consist of numbers, letters, underscores "_" and $, and numbers cannot begin.

There are special identifiers in Java, such as the class used to define classes, which are given specific meanings and usages, and these words are called keywords. Therefore, when using identifiers, you cannot conflict with these keywords.

Following the above two, the written identifier is legal, but in the actual application process, only legal is not enough, there are some more conventional provisions are to abide by. The most important principle of identifiers is to see the name of righteousness, in the program development, the use of the number of identifiers is huge, if you can not see the name of the meaning, management and maintenance is very troublesome.

When naming each thing, follow the appropriate rules:

Package: is the path used to differentiate the same class name

Name: all lowercase as java.util

Class (interface): the smallest unit of a Java program

Name: A word with the first letter capitalized as student Dog.

Multiple words the first letter of each word is capitalized as HelloWorld

method or variable: the code that completes a particular function, the data of the operation

Name: A word when all lowercase as main () age

Multiple words the second word begins with the first letter capitalized as Studentage

Constants: Used to store unchanging data

Name: A word with all letters capitalized as PI

Multiple words are capitalized in all letters, and the words are connected to each other like Max_age

The keyword mentioned above is that there is a specific meaning and special usage identifier in the Java language structure that cannot be used arbitrarily by the programmer, because each keyword has a specific usage, so it does not unfold here. The Java language has a total of 50 or so (specifically, not several), listed as follows:

Keywords to define the data type

class interface byte short int long float double char boolean void

Keywords to define data type values

True false null

Keywords to define Process Control

If else switch case default and do for break continue return

Keywords for defining access modifiers

Private protected public abstract final static synchronized

Keywords used to define the relationship between classes and classes

Extends implements

Used to define instance and reference instances, and to determine the keywords

New This super instanceof

Keywords for exception handling

Try Catch finally throw Throws

Keywords for the package

Package Import

Other modifier keywords

Native STRCTFP transient volatile assert

The beginning of the nameless world, the mother of all things----Java identifiers and keywords (3)

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.