Java编码规范
目 录
1 介绍(Introduction) 3
1.1 为什么要有编码规范(Why Have Code Conventions) 3
1.2 版权声明(Acknowledgments) .3
2 文件名(File Names) 3
2.1 文件后缀(File Suffixes)3
2.2 常用文件名(Common File Names) 3
3 文件组织(File Organization).4
3.1 Java 源文件(Java Source Files) 4
4 缩进排版(Indentation).5
4.1 行长度(Line Length) 5
4.2 换行(Wrapping Lines) 5
5 注释(Comments) 7
5.1 实现注释的格式(Implementation Comment Formats) 8
5.2 文档注释(Documentation Comments) 10
6 声明(Declarations) 11
6.1 每行声明变量的数量(Number Per Line) 11
6.2 初始化(Initialization)12
6.3 布局(Placement) 12
6.4 类和接口的声明(Class and Interface Declarations) .13
7 语句(Statements) .13
7.1 简单语句(Simple Statements) 13
7.2 复合语句(Compound Statements) 14
7.3 返回语句(return Statements) .14
7.4 if,if-else,if else-if else 语句(if, if-else, if else-if else Statements)14
7.5 for语句(for Statements) 15
7.6 while 语句(while Statements).15
7.7 do-while语句(do-while Statements) 16
7.9 try-catch语句(try-catch Statements) 17
8 空白(White Space) 17
8.1 空行(Blank Lines)17
8.2 空格(Blank Spaces) 18
9 命名规范(Naming Conventions)18
10 编程惯例(Programming Practices)20
10.1 提供对实例以及类变量的访问控制(Providing Access to Instance and Class Variables) 20
10.2 引用类变量和类方法(Referring to Class Variables and Methods)20
10.3 常量(Constants) .20
10.4 变量赋值(Variable Assignments) .20
10.5 其它惯例(Miscellaneous Practices).21
11 代码范例(Code Examples).23
11.1 Java 源文件范例(Java Source File Example)23