![](https://csdnimg.cn/release/download_crawler_static/86317180/bg14.jpg)
3.2.4 do-while....................................................................................................................................................................85
3.2.5 for.............................................................................................................................................................................. 86
3.2.6 ..............................................................................................................................................................87
3.2.7 ...........................................................................................................................................................................91
3.3
总结
..................................................................................................................................................................................94
3.4 练习..................................................................................................................................................................................94
第
4
章
初始化和清除
..............................................................................................................................................................95
4.1 用构建器自动初始化 ...................................................................................................................................................95
4.2 方法过载 .........................................................................................................................................................................96
4.2.1 .........................................................................................................................................................97
4.2.2 .........................................................................................................................................................98
4.2.3 ............................................................................................................................................................ 101
4.2.4 ............................................................................................................................................................ 102
4.2.5 this .............................................................................................................................................................102
4.3 清除:收尾和垃圾收集............................................................................................................................................105
4.3.1 finalize()................................................................................................................................................105
4.3.2 .......................................................................................................................................................106
4.4 成员初始化..................................................................................................................................................................108
4.4.1 ............................................................................................................................................................ 109
4.4.2 .......................................................................................................................................................111
4.5 数组初始化..................................................................................................................................................................116
4.5.1 ................................................................................................................................................................119
4.6 总结...............................................................................................................................................................................121
4.7 练习...............................................................................................................................................................................121
第
5
章
隐藏实施过程
...........................................................................................................................................................123
5.1 包:库单元..................................................................................................................................................................123
5.1.1 ..........................................................................................................................................124
5.1.2 .......................................................................................................................................................126
5.1.3 ..............................................................................................................................................128
5.1.4 ................................................................................................................................................................130
5.2 Java访问指示符 ........................................................................................................................................................130
5.2.1 ............................................................................................................................................................ 130
5.2.2 public ................................................................................................................................................131
5.2.3 private...........................................................................................................................................132
5.2.4 protected .............................................................................................................................. 133
5.3 接口与实现..................................................................................................................................................................134
5.4 类访问...........................................................................................................................................................................135
5.5 总结...............................................................................................................................................................................136
5.6 练习...............................................................................................................................................................................137
第
6
章
类再生
........................................................................................................................................................................139
6.1 合成的语法..................................................................................................................................................................139
6.2
继承的语法
..................................................................................................................................................................141
6.2.1 .......................................................................................................................................................143
6.3 合成与继承的结合 ....................................................................................................................................................145
6.3.1 ................................................................................................................................................... 146
6.3.2 ............................................................................................................................................................ 148
6.4 到底选择合成还是继承............................................................................................................................................149
6.5 protected....................................................................................................................................................................... 150
6.6 累积开发 ......................................................................................................................................................................151
6.7 上溯造型 ......................................................................................................................................................................151
6.7.1 ..........................................................................................................................................152
6.8 final关键字..................................................................................................................................................................152
6.8.1 final ................................................................................................................................................................152