ava源程序.....................11
1.4.4运行Java程序.........................12
1.4.5创建用于编译和运行Java程序
的批处理文件..........................13
1.5用JDeveloper软件来开发Java
应用............................................13
1.6小结............................................15
1.7编程实战:八戒用餐怀感恩....16
第2章基本语法了如指掌.....................19
2.1Java源文件结构........................19
2.2关键字........................................20
2.3标识符........................................21
2.4Java语言大小写敏感................22
2.5包声明语句................................22
2.6包引入语句................................24
2.7方法的声明................................26
2.8注释语句....................................27
2.9编程规范....................................28
2.10JavaDoc文档...........................28
2.11直接用JDK来编译和运行
本章范例....................................29
2.12用JDeveloper来编译和运行
本章范例....................................31
2.13用Eclipse来编译和运行
本章范例....................................33
2.14Java类库模块化......................36
2.15使用JShell交互式编程界面..38
2.16小结.........................................40
2.17编程实战:八戒吃瓜
美滋滋.......................................41
第3章数据类型齐争艳.........................43
3.1基本类型....................................44
3.1.1boolean类型.............................44
3.1.2byte、short、int和long
类型..........................................45
3.1.3char类型与字符编码...............46
3.1.4float和double类型.................47
3.2引用类型....................................47
3.3基本类型与引用类型的区别....48
3.4直接数........................................50
3.4.1直接数的类型..........................50
3.4.2直接数的赋值..........................51
3.5小结...........................................51
3.6编程实战:金箍棒的
电子档案...................................52
第4章千姿百态话变量.........................55
4.1变量的作用域............................55
4.1.1实例变量和静态变量..............57
4.1.2用静态变量统计实例的
个数..........................................59
4.1.3成员变量和局部变量同名.......60
4.2对象的默认引用:this..............60
4.3参数传递....................................61
4.4变量的初始化及默认值............63
4.4.1成员变量的初始化..................64
4.4.2局部变量的初始化..................65
4.4.3用new关键字创建对象..........65
4.5小结...........................................67
4.6编程实战:人参果树妙回春....69
第5章操作符号显身手.........................71
5.1操作符的优先级........................72
5.2整型操作符................................73
5.2.1一元整型操作符......................73
5.2.2二元整型操作符......................73
5.3浮点型操作符............................74
5.4比较操作符和逻辑操作符........75
5.4.1比较操作符..............................75
5.4.2逻辑操作符..............................76
5.5特殊操作符“?:”.......................78
5.6变量的赋值................................78
5.7基本数据类型转换....................79
5.7.1自动类型转换..........................79
5.7.2强制类型转换..........................80
5.8小结............................................81
5.9编程实战:判断年份是否为
闰年............................................82
5.10编程实战:数字加密..............83
第6章运筹帷幄控流程.........................85
6.1分支语句....................................86
6.1.1if...else语句.............................86
6.1.2switch语句..............................87
6.2循环语句....................................91
6.2.1while语句................................93
6.2.2do...while语句.........................94
6.2.3for语句....................................95
6.3流程跳转语句............................96
6.4小结............................................98
6.5编程实战:实现常用
数学运算....................................98
6.6编程实战:打印金字塔............99
6.7编程实战:考试分数和等级
转换..........................................100
6.8编程实战:数兔子..................101
6.9编程实战:寻找水仙花数......103
第7章代码重用靠继承.......................105
7.1继承的基本语法......................107
7.2方法重载(Overload)...........108
7.3方法覆盖(Override)............109
7.4方法覆盖与方法重载的
异同..........................................111
7.5super关键字............................112
7.6多态..........................................113
7.7小结..........................................115
7.8编程实战一:运用方法的重载
和覆盖.....................................115
7.9编程实战二:演绎孙悟空与
二郎神斗法.............................116
第8章引用类型操作符.......................121
8.1字符串连接操作符“+”..........121
8.2操作符“==”与对象的
equals()方法.............................122
8.2.1操作符“==”..........................122
8.2.2对象的equals()方法...............123
8.3操作符“!=”............................125
8.4引用变量的赋值和类型
转换.........................................126
8.5instanceof操作符....................127
8.6小结...........................................128
8.7编程实战:辨别真假
孙悟空.....................................129
第9章公私分明设权限.......................131
9.1封装类的部分属性和方法......132
9.24种访问控制级别...................133
9.3小结.........................................136
9.4编程实战:模拟自动
洗衣机.....................................136
第10章abstract:虚拟抽象画蓝图....141
10.1abstract修饰符的
修饰内容.................................141
10.2abstract修饰符的
语法规则.................................142
10.3抽象类不能被实例化............143
10.4小结.......................................144
10.5编程实战:金、银角大王的
魔法宝物.................................144
第11章final:一锤定音恒不变.........147
11.1final类...................................148
11.2final方法...............................148
11.3final变量...............................149
11.4小结........................................151
11.5编程实战:无法伪造篡改的
生死簿......................................152
第12章static:静态家当共分享.........155
12.1static变量...............................156
12.2static方法...............................156
12.2.1静态方法可访问的内容......157
12.2.2实例方法可访问的内容......158
12.2.3静态方法必须被实现..........159
12.3.4作为程序入口的main()方法
是静态方法............................159
12.3static代码块...........................160
12.4小结........................................161
12.5编程实战:灵活配置绘制
图形..........................................161
第13章对外开放靠接口.....................165
13.1接口的概念和语法规则........167
13.2比较抽象类与接口................169
13.3小结........................................171
13.4编程实战:紧箍圈降伏诸
顽劣..........................................172
第14章出生入死话对象.....................175
14.1对象的构造方法....................176
14.1.1重载构造方法......................177
14.1.2默认构造方法......................178
14.1.3子类调用父类的构造
方法........................................179
14.2垃圾回收................................182
14.2.1垃圾回收的时机..................183
14.2.2对象的finalize()方法...........184
14.3小结........................................185
14.4编程实战:玩转垃圾回收....186
14.5编程实战:独一无二
玉净瓶......................................188
第15章类型封装内部类.....................189
15.1内部类的种类........................191
15.2成员内部类............................191
15.2.1实例内部类..........................192
15.2.2静态内部类..........................195
15.3局部内部类............................196
15.4匿名类....................................197
15.5用Lambda表达式代替
内部类.....................................199
15.6小结.......................................200
15.7编程实战:内部类回调
外部类.....................................201
第16章降伏异常有策略.....................203
16.1Java异常处理机制概述........204
16.2运用Java异常处理机制.......207
16.2.1try...catch语句:捕获
异常........................................207
16.2.2finally语句:任何情况下
必须执行的代码....................208
16.2.3throws子句:声明可能会
出现的异常............................209
16.2.4throw语句:抛出异常........210
16.2.5异常处理语句的语法
规则........................................210
16.2.6异常流程的运行过程..........213
16.3Java异常类...........................214
16.3.1运行时异常..........................217
16.3.2受检查异常
(CheckedException).........217
16.3.3区分运行时异常和
受检查异常............................217
16.4用户定义异常........................219
16.5小结.......................................220
16.6编程实战:囧途开车遇
异常.........................................221
第17章数组元素排排座.....................225
17.1数组简介................................227
17.2数组变量的声明....................227
17.3创建数组对象........................227
17.4访问数组的元素和长度........229
17.5数组的初始化........................230
17.6数组排序................................231
17.7多维数组................................232
17.8用符号“…”声明数目
可变参数..................................233
17.9小结........................................234
17.10编程实战:多位数字
加密..........................................235
17.11编程实战:用数组实现
堆栈..........................................236
第18章集合元素大操练.....................239
18.1Java集合的类框架................240
18.2集合的基本用法....................240
18.2.1包装类的自动装箱和
拆箱........................................241
18.2.2Set(集)和List(列表)
的各种具体实现类的特点....241
18.2.3集合的静态of()方法...........243
18.3List(队列)..........................245
18.4Map(映射).........................245
18.5用Lambda表达式遍历
集合..........................................247
18.6小结........................................248
18.7编程实战:计算数学
表达式......................................248
18.8编程实战:计算带括号的
数学表达式..............................252
18.9编程实战:用集合工具对
数字排序..................................255
18.10编程实战:按月份先后
顺序数兔子..............................256
18.11编程实战:用映射来存放
学生信息..................................257
18.12编程实战:圆桌报数
游戏..........................................259
第19章数据出入靠I/O.......................261
19.1输入流和输出流概述............262
19.2输入流....................................263
19.3FilterInputStream
(过滤输入流)......................264
19.3.1BufferedInputStream类........265
19.3.2DataInputStream类..............265
19.4输出流....................................267
19.5FilterOutputStream
(过滤输出流).....................267
19.5.1DataOutputStream................267
19.5.2BufferedOutputStream..........268
19.5.3PrintStream类......................268
19.6Reader/Writer概述................269
19.7Reader类...............................271
19.7.1InputStreamReader类..........271
19.7.2FileReader类........................271
19.7.3BufferedReader类................272
19.8Writer类................................272
19.8.1OutputStreamWriter类.........273
19.8.2FileWriter类.........................273
19.8.3BufferedWriter类.................273
19.8.4PrintWriter类.......................273
19.9读写文本文件的范例............274
19.10随机访问文件类:
RandomAccessFile..................276
19.11File类..................................277
19.12用java.nio.file类库来
操纵文件系统.........................279
19.13小结......................................282
19.14编程实战:替换文本文件中
的字符串.................................283
19.15编程实战:批量修改
文件名.....................................285
第20章并发运行多线程.....................287
20.1Java线程的运行机制............288
20.2线程的创建和启动................289
20.2.1扩展java.lang.Thread类......289
20.2.2实现java.lang.Runnable
接口........................................291
20.3线程的状态转换....................293
20.3.1新建状态(New)...............293
20.3.2就绪状态(Runnable).......293
20.3.3运行状态(Running).........293
20.3.4阻塞状态(Blocked).........294
20.3.5等待状态(Waiting)..........294
20.3.6死亡状态(Terminated)....294
20.3.7线程状态转换举例..............294
20.4线程调度................................295
20.4.1调整各个线程的优先级......296
20.4.2线程睡眠:Thread.sleep()
方法........................................297
20.4.3线程让步:Thead.yield()
方法........................................298
20.4.4等待其他线程结束:
join().......................................299
20.5获得当前线程对象的引用....300
20.6小结........................................301
20.7编程实战:孙悟空偷吃
蟠桃..........................................302
第21章同步通信多线程.....................305
21.1线程的同步............................307
21.1.1同步代码块..........................310
21.1.2线程同步的特征..................312
21.2线程的通信............................314
21.3小结........................................318
21.4编程实战:悟空保唐僧打
群妖..........................................319
21.5编程实战:运动员赛跑........322
21.6编程实战:秒针、分针和
时针的通信..............................324
第22章图形界面俏容颜.....................327
22.1图形用户界面的构建机制....327
22.2容器类组件............................329
22.3布局管理器............................331
22.3.1FlowLayout流式布局
管理器....................................333
22.3.2BorderLayout边界布局
管理器....................................334
22.3.3GridLayout网格布局
管理器....................................336
22.3.4CardLayout卡片布局
管理器....................................338
22.4事件处理................................340
22.5AWT绘图..............................343
22.6创建动画................................346
22.7菜单.......................................348
22.8小结.......................................350
22.9编程实战:创建数学
计算器.....................................352
22.10编程实战:创建BMI指数
计算器.....................................353
第23章轻松访问数据库.....................359
23.1安装和配置MySQL
数据库.....................................360
23.2JDBCAPI简介......................362
23.3JDBCAPI的基本用法..........365
23.4获得新插入记录的主键值....368
23.5封装连接数据库的细节........369
23.6处理SQLException...............374
23.7设置批量抓取属性................375
23.8可滚动及可更新的
结果集.....................................376
23.9小结.......................................383
23.10编程实战:创建客户
管理器.....................................383