目录
序言
前言
第一章 集合框架和泛型 ··························································································· 1
任务1 查询标题 ·························································································· · 2
任务2 查询标题功能升级························································································ 18
2.2.1 认识泛型 ······································································································ 18
2.2.2 深入泛型 ······································································································· 21
本章总结 ························································································································ 25
本章练习 ························································································································ 25
第二章 实用类 ················································································································27
任务1 使用java.lang包中的常用类 ····································································· 28
2.1.1 java API介绍 ······························································································· 28
2.1.2 认识枚举···········································································································29
2.1.3 包装类··············································································································31
2.1.4 Math类33
任务2 操作字符串·····································································································34
2.2.1 String类的常用方法······················································································35
2.2.2 StringBuffer类和Stringbuilder类·····························································41
任务3 使用java.util包中的常用类············································································44
3.1.1 日期操作类·······································································································44
3.1.2 Random类······································································································· 46
本章总结····························································································································48
本章练习·····························································································································48
第三章 Java I/O和反射机制····························································································51
任务1 使用I/O操作文件····························································································52
3.1.1 操作文件或目录属性······················································································52
3.1.2 认识Java的流······························································································· 54
3.1.3 读写文本文件··································································································57
3.1.4 读写二进制文件······························································································63
3.1.5 重定向标准I/O·······························································································65
任务2 使用对象流读写对象信息·········································································· 66
3 .2.1 认识序列化···································································································66
3.2.2 序列化保存对象信息····················································································66
3.2.3 反序列化获取对象信息·················································································68
3.2.4 对象引用的序列化··························································································70
任务3 使用反射机制·····································································································70
3.3.1 认识反射·········································································································70
3.3.2 反射的应用·····································································································72
本章总结······························································································································80
本章练习······························································································································81
第四章 注解与多线程·········································································································83
任务1 使用注解描述程序代码·····················································································84
4.1.1 认识注解·············································································································84
4.1.2 注解分类·············································································································85
4.1.3 读取注解信息······································································································88
任务2 使用多线程输出数列··························································································89
4.2.1 认识线程·············································································································89
4.2.2 编写线程类·········································································································90
4.2.3 线程的状态··········································································································93
4.2.4 线程调度··············································································································94
任务3 使用线程同步模拟银行取款···········································································100
4.3.1 线程同步的必要性···························································································100
4.3.2 实现线程同步····································································································103
任务4 生产者消费者问题····························································································105
4.4.1 线程问题的必要性···························································································105
4.4.2 实现线程间通信·······························································································106
本章总结···························································································································110
本章练习···························································································································111
第五章 Java网络编程···································································································113
任务1 查看IP 地址····································································································114
5.1 .1 认识网络········································································································114
5.2 .2 IP地址············································································································117
5.3 .3 重要概念介绍·······························································································123
任务2 实现基于TCP协议的Socket编程·······························································123
5.2.1 认识Socket·····································································································124
5.2.2 基于TCP协议的Socket编程······································································126
5.2.3 使用Socket编程实现登录功能···································································131
任务3 实现基于UDP协议的Socket编程································································132
5.3.1 基于UDP协议的Socket编程·····································································133
5.3.2 使用Socket编程实现客户咨询··································································135
任务4 搭建JUnit测试框架························································································135
5.4.1 JUnit测试框架·······························································································136
5.4.2 JUnit 3.x测试框架·······················································································137
5.4.3 JUnit 4.x测试框架··························································································138
5.4.4 测试套件·········································································································· 140
本章总结···························································································································140
本章练习···························································································································140
第六章 XML技术·······································································································143
任务1 使用XML存储数据····························································································144
6.1.1 认识XML144
6.1.2 XML文档结构···································································144
6.1.3 XML优势································································································147
6.1.4 XML中的命名空间·························································································147
任务2 XML文档的验证·······························································································148
6.2.1 使用DTD 验证XML文档··············································································149
6.2.2 使用Schema验证XML文档········································································151
任务3 使用DOM 解析XML·························································································155
6.3.1 XML解析··········································································································155
6.3.2 使用DOM读取XML数据··············································································156
6.3.3 使用DOM维护XML数据···············································································161
任务4 使用DOM4J 解析XML····················································································163
6.4.1 DOM4J 解析····································································································164
6.4.2 使用DOM4J 操作XML··················································································164
本章总结·····························································································································169
本章练习·····························································································································169
第七章 综合实战——嗖嗖移动业务大厅····································································171
7.1 项目需求···············································································································172
7.2 项目环境准备·······································································································173
7.3 案例覆盖的技能点·······························································································173
7.4 难点分析··············································································································173
7.5 项目实现思路·······································································································178
本章总结····························································································································192
本章练习················································································································· ··········192
附录·····································································································································193
附录1 Java常用API学习方法················································································· 193
附录2 Java中常用编码格式及I/O 操作中的编码··································193