目 录
1 概述.................................................................................................................................................3
1.1 编程规范的必要性..............................................................................................................3
1.2 规范文档的一些要求..........................................................................................................3
1.3 如何使代码简洁..................................................................................................................3
2 源文件的组织.................................................................................................................................4
2.1 Java 源文件..........................................................................................................................4
2.1.1 文档开头的注释.......................................................................................................4
2.1.2 Package 和 Import 声明............................................................................................4
2.1.3 类和接口声明...........................................................................................................5
3 文档的缩进规则.............................................................................................................................5
3.1 行的长度..............................................................................................................................5
3.2 代码行的分割......................................................................................................................5
4 代码的注释规则.............................................................................................................................7
4.1 代码注释的基本原则..........................................................................................................8
4.2 注释的运用..........................................................................................................................8
4.3 Implementation 注释的格式................................................................................................8
4.3.1 块注释.......................................................................................................................8
4.3.2 单行注释...................................................................................................................9
4.3.3 后注释(trailing)(不提倡使用)..................................................................................9
4.3.4 行尾注释(End-of-line)..............................................................................................9
4.4 文档型注释(Documentation)............................................................................................10
4.4.1 位置.........................................................................................................................10
4.4.2 javadoc 标签的使用...............................................................................................12
4.4.3 加入样例代码.........................................................................................................12
4.4.4 生成 javadoc 文档...................................................................................................12
5 变量的声明...................................................................................................................................14
5.1 每行变量声明个数............................................................................................................14
5.2 变量初始化........................................................................................................................14
5.3 变量声明的位置................................................................................................................14
5.4 类和接口的声明................................................................................................................15
6 语句...............................................................................................................................................15
6.1 简单语句............................................................................................................................15
6.2 复合语句............................................................................................................................16
6.3 返回语句............................................................................................................................16
6.4 if,if-else,if else-if else 语句..........................................................................................16
6.5 for 语句..............................................................................................................................17
6.6 while 循环语句..................................................................................................................17
6.7 do-while 语句.....................................................................................................................17
6.8 switch 语句.........................................................................................................................17
6.9 try-catch 语句.....................................................................................................................18
7 空行和空格的使用.......................................................................................................................18
第 1 页
评论0
最新资源