I. Naming rules for identifiers 1. Identifiers are used to name variables, methods and classes.
2. Start with letters, underscores "_" and "$", followed by letters, underscores "_" and "$" or numbers.
3. Case-sensitive.
4. Use meaningful names to know the meaning of names, and the length is not limited.
5. Try not to use Chinese.
6. It can't be true or false.
True or false is not a key word, but it has a special purpose.
7. Avoid having the same name as java keywords and class names of java class libraries. There are 5 1 java keywords.
2. Use different naming rules for different identifiers 1. Package name: all lowercase, separated by ".". Each point represents a first-level directory, and there must be at least one first-level directory.
(1) Single-level package: lowercase.
Such as: com(2) multi-level package: lowercase, separated by ".".
2. Class or interface: All words are capitalized.
(Big Hump Method) (1) One word: capitalized.
Such as: students, people (2) multiple words: the first letter of each word is capitalized.
For example: HelloWorld, ServerSocket3, method or variable: the first word is lowercase, and the first letter is capitalized from the second word.
(Small Hump Method) (1) One word: the first letter is lowercase.
Such as: name, age (2) multiple words: the first letter of the second word is capitalized.
For example: stuName, showTime4, constant: all caps, word key underlined "_" (1) One word: all caps.
For example: PI, COUNT(2) Multiple words: all capitalized, separated by "_".
For example: RESULT_OK, WINDOW_HIERARCHY_TAG. In a word, following this naming convention will not only help others to read our code faster and understand the members in the code, but also reduce many unnecessary troubles in actual development.