JAVA identifier proposition rules and habits

1. Identifier naming rules (used to name variables, methods and classes)
1. Start with a letter, underscore _, or the character $, followed by numbers, letters, underscore _ and
$.
2. Case sensitive
3. Identifiers cannot be keywords, such as int, float, etc.
4. Identifiers cannot be true, false and null (although true, false, and null are not java keywords). The
above is the propositional rule of JAVA, yes Grammatically, it means mandatory and cannot be wrong.
2. Identity naming convention
1. Package name: all lowercase, separated by ".", each dot represents a first-level directory, and at least a first-level directory.

(1) Single-level package: lowercase. Such as: com

(2) Multi-level package: lowercase, separated by ".". Such as: com.baidu.www

2. Class or interface: capitalize the first letter of all words. (Big Hump Method)

(1) A word: capitalize the first letter. Such as: Student, People

(2) Multiple words: Capitalize the first letter of each word. Such as: HelloWorld, Test

3. Method or variable: the first letter of the first word is lowercase, and the first letter of the second word is uppercase. (Little Hump Method)

(1) A word: lowercase the first letter. Such as: name, age

(2) Multiple words: Capitalize the first letter of the second word. Such as: studentName

4. Constants: all capitals, separated by underscores "_"

(1) One word: all capitals. Such as: SUM, COUNT

(2) Multiple words: all capitals and separated by "_". Such as: RESULT_OK, WINDOW_HIERARCHY_TAG

Guess you like

Origin blog.csdn.net/zzc15768234368/article/details/108959021