Java basics-Keyword vs identifier, java keyword vs identifier

Source: Internet
Author: User

Java basics-Keyword vs identifier, java keyword vs identifier

Although the keywords and identifiers have little to do with each other, since these two words often appear together, let's sort them out.

Keywords

Definition:

A word that is given a special meaning by the Java language.

Features:

All letters are in lowercase. (A color is displayed in many programming software)

CATEGORY list:

A. keywords used to define data types

Class

Interface

Byte

Short

Int

Long

Float

Double

Char

Boolean

Void

 

 

 

 

B. keywords used to define data type values

True

False

Null

C. keywords used to define Process Control

If

Else

Switch

Case

Default

While

Do

For

Break

Continue

Return

 

 

 

 

Note: Although goto and const are never used, they still exist as reserved words (which may be promoted to keywords in the new JDK version.

 

Identifier

Definition:

The name of a class, variable/constant, method (function), or statement block during programming.

Composition rules:

A. It consists of numbers 0-9, 26 English letters in upper and lower case, $ and;

B. It cannot start with a number;

C. It cannot be a keyword.(I finally got in touch with the keyword)

D. Do not use spaces in the name.

E. Strictly case sensitive in Java

Common naming rules:

A: Package

Stores files with the same name in different directories.

All lowercase letters. For multi-level packages, use. to separate them.

Example: itcast, cn. itcast, com. baidu

Project for the company: domain name anti-writing is the package name.

B: class and interface (see,)

A: The first letter of a word is capitalized.

Example: Student, Teacher

B: It is composed of multiple words, and the first letter of each word is capitalized.

Example: HelloWorld, HaoGuiBao

C: Methods and variables

A: lowercase for a word.

Example: main (), age

B: If it is composed of multiple words, the first letter of each word is capitalized starting from the second word.

Example: showName (), studentAge

D: Constant

A: If it is a word, all uppercase letters are used.

Example: PI

B: If multiple words are entered, all uppercase words are separated _.

Example: STUDENT_MAX_AGE


Summary:

Keywords are defined by the language itself, and identifiers are named by ourselves. These words are used to allow us to better understand the program and unify everyone's cognition, this enables good communication between programmers and machines. Although there are many rules and regulations, they are worth observing.

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.