1. Java file name and file organization structure.
1. the Java file name consists of the actual file name + suffix. The suffix name varies depending on the type. The suffix of the Java source file is. Java, and the suffix of the Java bytecode file is. Class.
2. In general, the structure of the Java source file is that each sectionCodeEach section is separated by a blank line. Normally, the Java source file should not exceed 2000 lines. Otherwise, the class is "bloated ".
3. Each Java source file is generally composed of the following sequence.
(1) file comment header.
(2) package name ).
(3) Import Statement.
(4) class or interface declaration.
Ii. Java file comment header.
1. the Java class file comment header is used to describe the functions and features of this class and related development information. For example, the format is as follows:
/*** Description of the functions and features of this class (for example, this class is used ......) <br/> ** this type has not been compiled and tested <br/> ** development company or organization: capability Co., Ltd. <br/> ** copyright: capability Limited R & D center <br/> ** @ see (class associated with this class): (file. class) <br/> ** @ Author: Bill Gates <br/> ** @ since: jdk1.6 <br/> ** @ version: v1.x-beta <br/> ** @ Date: 11:11:11 <br/> ** last modification date: 12:12:12 <br/> ** modified: jobs <br/> ** reviewer: Obama Hillary Clinton <br/> **/
3. Package declaration and reference.
1. The package name must be unique.
2. The package name is usually a lowercase ASCII letter.
3. The package name is generally the reverse order of the Company domain name. Frequently Used domain names include CN, COM, Edu, Gov, Mil, net, and org.
4. A country name before a domain name can be prefixed with one or two English letters to indicate the country name. This rule can be referred to in ISO 3166.
5. You can name the part after the domain name according to your habits.
4. Java source file orchestration format.
1. The line indent in the general orchestration format is in the unit of four space keys. In addition, a tab key contains eight spaces.
2. The length of the code line. Generally, Java code lines should be less than 80 characters in length.
3. Discount rules.
(1) fold the lines after a comma.
(2) fold before the operator.
(3) superior to lower-layer fold.
(4) The broken lines of code should be left aligned with the lines of code of the same level.
(5) If the preceding rule makes the right side of the code line much different from the page edge, we can use the tab key in the appropriate line.
5. Rules for space and empty rows.
1. Space Application rules.
(1) spaces are generally used between keywords and parentheses. Note: The method name and left parenthesis should not be separated by spaces. Example: While (true ){}
(2) Insert a space after a comma in the parameter list. Example: Process (arg1, arg2,..., argn)
(3) spaces should be added between the operands and operators of the mathematical formula. Example: x = XX> 3; A = (a + B)/(c * D)
(4) The expressions in the for statement should be separated by semicolons. Example: For (expr1; expr2; expr3)
(5) The right brackets of the forced type in the forced type conversion statement should be separated by commas. Example: (byte) num
2. empty row application rules.
(1) Insert two blank lines between two code snippets of the same source file or between the class and Interface Definition of the same source file.
(2) Insert a blank row in the following cases. A). Between two methods. B). Between the local variable in the method and the first statement. C). Before the block comment and single line comment. D). Between the logical segments in the method.