您好,欢迎光临本网站![请登录][注册会员]  
文件名称: JAVA程序设计教程
  所属分类: Java
  开发工具:
  文件大小: 3mb
  下载次数: 0
  上传时间: 2013-09-07
  提 供 者: yuanxi******
 详细说明: 目录 引言 ...................................................................................................................................... I 第一章程序和程序设计 .......................................................................................................1 §1.1 什么是程序 ?............................................................................................................1 1.1.1 算法.................................................................................................................2 1.1.2 实体.......... .......................................................................................................3 1.1.3 程序.................................................................................................................3 1.1.4 程序设计 .........................................................................................................4 §1.2 程序设计方法与语言 ..............................................................................................5 1.2.1 早期的程序设计 .............................................................................................5 1.2.2 结构化程序设计 .............................................................................................5 1.2.3 面向对象程序设计 .........................................................................................6 §1.3 一个完整的 Java程序.............................................................................................6 1.3.1 Java程序的结构 ..............................................................................................8 1.3.2 Java程序的退化结构 ......................................................................................9 1.3.3 Java程序的运行 ............................................................................................10 1.3.4 Java程序的调试 ............................................................................................11 §1.4 面向对象程序的构造 ............................................................................................11 内容小结.........................................................................................................................12 思考与练习.....................................................................................................................12 上机实习题.....................................................................................................................12 小课题:抽象与抽象层次.............................................................................................13 小课题:程序设计语言的历史.....................................................................................13 第二章基本数据类型 .........................................................................................................14 §2.1 数据类型概述 ........................................................................................................14 2.1.1 什么是类型? ...............................................................................................14 2.1.2 类型的作用 ...................................................................................................14 2.1.3 Java语言的类型 ............................................................................................15 §2.2 程序中的单词 ........................................................................................................15 2.2.1 单词分类 .......................................................................................................15 2.2.2 保留字...........................................................................................................15 2.2.3 标识符...........................................................................................................16 2.2.4 程序中的空白 ...............................................................................................16 §2.3 变量与赋值 ............................................................................................................17 2.3.1 确定数据类型 ...............................................................................................17 2.3.2 变量的要素 ...................................................................................................17 2.3.3 赋值运算 .......................................................................................................18 2.3.4 程序的输出 ...................................................................................................18 §2.4 Java语言的简单类型 .............................................................................................18 2.4.1 字符类型 .......................................................................................................19 2.4.2 整数类型 .......................................................................................................19 2.4.3 浮点数类型和双精度浮点数类型 ...............................................................20 2.4.4 布尔类型 .......................................................................................................20 2.4.5 字符串类型 ...................................................................................................21 2.4.6 符号常量 .......................................................................................................21 §2.5 表达式....................................................................................................................22 - i - 2.5.1 表达式...........................................................................................................22 2.5.2 算术运算 .......................................................................................................22 2.5.3 关系运算 .......................................................................................................23 2.5.4 逻辑运算 .......................................................................................................23 2.5.5 类型转换 .......................................................................................................24 2.5.6 一个小小应用程序 .......................................................................................24 §2.6 编写简单应用程序 ................................................................................................25 2.6.1 最简单的程序 ...............................................................................................25 2.6.2 引入变量的程序 ...........................................................................................26 2.6.3 程序的输入 ...................................................................................................26 2.6.4 完整的程序 ...................................................................................................27 内容小结.........................................................................................................................28 思考与练习.....................................................................................................................28 上机实习题.....................................................................................................................29 小课题:构造性思维方法.............................................................................................29 第三章基本控制结构 .........................................................................................................30 §3.1 简单语句 ................................................................................................................30 §3.2 结构化控制结构 ....................................................................................................30 3.2.1 程序的控制结构 ...........................................................................................30 3.2.2 结构化程序设计工具 ...................................................................................31 3.2.3 盒图与伪码 ...................................................................................................31 §3.3 选择结构 ..............................................................................................................33 3.3.1 不带 else的 if语句 ......................................................................................33 3.3.2 带 else的 if语句 ..........................................................................................35 3.3.3 嵌套 if语句 ..................................................................................................36 3.3.4 垂悬 else问题 ..............................................................................................38 §3.4 循环结构 ..............................................................................................................39 3.4.1 while语句......................................................................................................39 3.4.2 break语句和 continue语句 ..........................................................................42 3.4.3 do_while语句................................................................................................44 3.4.4 for语句..........................................................................................................46 §3.5 原始算法与精美算法 ............................................................................................47 3.5.1 求解问题的精美算法 ...................................................................................47 3.5.2 求解问题的原始算法 ...................................................................................48 §3.6 一个应用程序例子 ................................................................................................48 内容小结.........................................................................................................................50 思考与练习.....................................................................................................................51 上机实习题.....................................................................................................................52 第四章方法.........................................................................................................................53 §4.1 例程机制 ................................................................................................................53 4.1.1 分而治之与软件重用 ...................................................................................53 4.1.2 Java语言的方法 ............................................................................................54 4.1.3 两个例子 .......................................................................................................54 §4.2 方法的声明与调用 ................................................................................................56 4.2.1 方法的声明 ...................................................................................................56 4.2.2 方法的调用 ...................................................................................................57 4.2.3 方法的接口与实现 .......................................................................................58 §4.3 方法的参数 ............................................................................................................59 4.3.1 参数设计 .......................................................................................................59 4.3.2 按值调用 .......................................................................................................61 §4.4 标识符的作用域 ....................................................................................................61 - ii - 4.4.1 作用域规则 ...................................................................................................62 4.4.2 标识符命名冲突 ...........................................................................................63 §4.5 使用 Java API ........................................................................................................63 4.5.1 数值运算 .......................................................................................................63 4.5.2 伪随机数 .......................................................................................................64 §4.6 递归程序设计 ........................................................................................................65 4.6.1 简单递归程序 ...............................................................................................65 4.6.2 梵塔问题 .......................................................................................................66 内容小结.........................................................................................................................67 思考与练习.....................................................................................................................68 上机实习题.....................................................................................................................69 小课题:计算机辅助教学.............................................................................................69 第五章类与对象 .................................................................................................................70 §5.1 声明一个类 ............................................................................................................70 5.1.1 类的声明 .......................................................................................................70 5.1.2 类成员的访问控制 .......................................................................................71 5.1.3 类作用域 .......................................................................................................72 §5.2 创建对象实例 ........................................................................................................73 5.2.1 对象的声明与使用 .......................................................................................73 5.2.2 对象的初始化 ...............................................................................................74 5.2.3 静态成员 .......................................................................................................76 5.2.4 对象的参数传递方式 ...................................................................................78 §5.3 变量和对象实例的生存期 ....................................................................................79 5.3.1变量的生存期 ................................................................................................80 5.3.2对象实例的生存期 ........................................................................................80 §5.4 字符串类 String.....................................................................................................82 5.4.1 使用 String类型的对象 ...............................................................................82 5.4.2 类 String的主要方法 ...................................................................................82 5.4.3 使用字符串对象的例子 ...............................................................................84 §5.5 关于类和对象的进一步讨论 ................................................................................86 5.5.1 基本数据类型的包装类 ...............................................................................86 5.5.2 抽象数据类型 ...............................................................................................87 5.5.3 设计良好的类接口 .......................................................................................88 5.5.4 再论对象 .......................................................................................................88 5.5.5 再论 Java语言的类......................................................................................89 内容小结.........................................................................................................................90 思考与练习.....................................................................................................................90 上机练习题.....................................................................................................................92 小课题:命令行交互方式.............................................................................................92 第六章复合数据类型 .........................................................................................................93 §6.1 使用数组变量 ........................................................................................................93 6.1.1 数组变量的声明 ...........................................................................................93 6.1.2 访问数组元素 ...............................................................................................94 6.1.3 数组作为参数传递 .......................................................................................95 §6.2 数组应用举例 ........................................................................................................96 6.2.1 学生成绩管理 ...............................................................................................96 6.2.2 完整的程序 ...................................................................................................96 6.2.3 冒泡排序法 ...................................................................................................99 §6.3 使用二维数组变量 ..............................................................................................100 6.3.1 什么是二维数组? .....................................................................................100 6.3.2 使用二维数组 .............................................................................................101 - iii - 6.3.3 二维数组应用举例 .....................................................................................101 §6.4 一个扑克牌游戏程序 ..........................................................................................102 6.4.1 分析问题 .....................................................................................................102 6.4.2 建模.............................................................................................................103 6.4.3 完整的程序 .................................................................................................103 §6.5 高级数据结构的构造 ..........................................................................................106 §6.6 对象实例的复制与比较 ......................................................................................108 6.6.1 对象实例的复制 .........................................................................................108 6.6.2 对象实例的比较 .........................................................................................112 内容小结.......................................................................................................................113 思考与练习...................................................................................................................113 上机实习题...................................................................................................................115 第七章继承与多态 ...........................................................................................................116 §7.1 继承的基本概念 ..................................................................................................116 7.1.1 IS-A关系..................................................................................................116 7.1.2 继承机制 .....................................................................................................116 7.1.3 继承的作用 .................................................................................................117 7.1.4 继承与软件重用 .........................................................................................118 §7.2 Java语言的继承机制 ...........................................................................................118 7.2.1 继承的语法 .................................................................................................118 7.2.2 继承与成员访问控制 .................................................................................120 7.2.3 继承成员的调整 .........................................................................................121 7.2.4 子类对象实例的存储组织 .........................................................................122 7.2.5 继承与对象初始化及收尾 .........................................................................124 7.2.6 继承与子类型 .............................................................................................125 §7.3 多态性的基本概念 ..............................................................................................126 7.3.1 程序的多态性 .............................................................................................126 7.3.2 表示独立性 .................................................................................................127 §7.4 方法重载 ..............................................................................................................127 7.4.1 方法重载的途径 .........................................................................................128 7.4.2 方法重载的二义性 .....................................................................................130 7.4.3 构造方法的重载 .........................................................................................133 §7.5 动态绑定 ..............................................................................................................133 §7.6 对继承和多态的进一步讨论 ..............................................................................135 7.6.1 单继承与多继承 .........................................................................................135 7.6.2 最终类与抽象类 .........................................................................................136 7.6.3 类属机制 .....................................................................................................139 7.6.4 类层次设计 .................................................................................................140 内容小结.......................................................................................................................141 思考与练习...................................................................................................................142 上机实习题...................................................................................................................146 小课题:为 Java语言引入类属机制 ..........................................................................147 第八章接口与程序包 .......................................................................................................148 §8.1 接口......................................................................................................................148 8.1.1 接口的作用 .................................................................................................148 8.1.2 接口的声明 .................................................................................................149 8.1.3 接口与类 .....................................................................................................150 8.1.4 接口的继承 .................................................................................................154 8.1.5 接口与多态性 .............................................................................................155 §8.2 程序包..................................................................................................................157 8.2.1 Java程序的组织 ..........................................................................................157 - iv - 8.2.2 程序包的定义 .............................................................................................158 8.2.3 程序包的引入 .............................................................................................159 8.2.4 包级访问控制 .............................................................................................161 8.2.5 Java的系统程序包 ......................................................................................163 §8.3 嵌套类..................................................................................................................164 8.3.1 嵌套类的种类 .............................................................................................164 8.3.2 内部类.........................................................................................................165 8.3.3 回调机制 .....................................................................................................168 8.3.4 静态类.........................................................................................................171 内容小结.......................................................................................................................171 思考与练习...................................................................................................................172 上机实习题...................................................................................................................177 第九章异常处理与断言 ...................................................................................................178 §9.1 异常处理的基本概念 ..........................................................................................178 9.1.1 异常处理 .....................................................................................................178 9.1.2 异常处理的模式 .........................................................................................179 §9.2 Java语言的异常处理机制 ...................................................................................180 9.2.1 异常的分类 .................................................................................................180 9.2.2 Java标准异常简介 ......................................................................................181 9.2.3 异常的捕获与处理 .....................................................................................182 9.2.4 异常的匹配 .................................................................................................184 9.2.5 异常处理与收尾 .........................................................................................184 9.2.6 异常处理与构造方法 .................................................................................186 9.2.7 异常的转发 .................................................................................................187 9.2.8 异常声明与方法重载 .................................................................................188 9.2.9 异常处理与继承机制 .................................................................................188 §9.3 程序断言机制 ......................................................................................................191 9.3.1 程序断言 .....................................................................................................191 9.3.2 程序断言的用法 .........................................................................................192 9.3.3 在 Java语言中实现部分断言....................................................................193 内容小结.......................................................................................................................195 思考与练习...................................................................................................................195 上机实习题...................................................................................................................197 第十章输入/输出流 .......................................................................................................198 §10.1输入/输出基本概念 ........................................................................................198 10.1.1 外部设备与文件 .......................................................................................198 10.1.2 文件的基本概念 .......................................................................................198 10.1.3 输入/输出流 ...........................................................................................199 §10.2 Java流系统概述 .................................................................................................199 10.2.1 面向字节的输入流类 ...............................................................................200 10.2.2 面向字节的输出流类 ...............................................................................201 10.2.3 面向字符的输入流类 ...............................................................................203 10.2.4 面向字符的输出流类 ...............................................................................204 10.2.5 Java API定义的流对象 ............................................................................205 §10.3文件流................................................................................................................206 10.3.1 文件及文件目录的操作 ...........................................................................206 10.3.2 文件内容的顺序读写 ...............................................................................208 10.3.3 文件内容的随机读写 ...............................................................................209 §10.4过滤器流 ............................................................................................................210 10.4.1 装饰模式 ...................................................................................................210 10.4.2 数据转换流 ...............................................................................................211 - v - 10.4.3 带行号的输入流 .......................................................................................212 10.4.4 设计自己的过滤器流 ...............................................................................213 §10.5对象串行化 ........................................................................................................215 10.5.1 对象串行化的作用 ...................................................................................215 10.5.2 对象串行化的基本方法 ...........................................................................216 10.5.3 串行化自己的对象 ...................................................................................217 §10.6其它类型的流简介 ............................................................................................219 10.6.1 管道流 .......................................................................................................219 10.6.2 连接流 .......................................................................................................220 内容小结.......................................................................................................................221 思考与练习...................................................................................................................222 上机实习题...................................................................................................................222 小课题:设计词法分析程序.......................................................................................223 第十一章对象容器...........................................................................................................224 §11.1 对象容器的基本概念 ........................................................................................224 §11.2 Java对象容器概述 .............................................................................................225 11.2.1 Java对象容器接口及其骨架类 ................................................................225 11.2.2 Java的对象容器类 ....................................................................................226 11.2.3支持对象容器的辅助工具 ........................................................................228 §11.3 迭代器................................................................................................................229 11.3.1迭代器设计模式 ........................................................................................229 11.3.2迭代器的基本用法 ....................................................................................230 11.3.3列表专用迭代器 ........................................................................................230 11.3.4旧版本的枚举接口 ....................................................................................232 §11.4 类集容器 ............................................................................................................232 11.4.1类集容器接口 ............................................................................................232 11.4.2列表容器 ....................................................................................................235 11.4.3集合容器 ....................................................................................................238 §11.5 映射容器 ............................................................................................................240 11.5.1映射容器接口 ............................................................................................240 11.5.2映射容器类 ................................................................................................245 §11.6 对象容器操纵工具 ............................................................................................247 11.6.1数组操纵工具 ...........................................................................................247 11.6.2容器操纵工具 ...........................................................................................249 内容小结.......................................................................................................................251 思考与练习...................................................................................................................252 上机实习题...................................................................................................................253 小课题:对象容器的性能比较...................................................................................253 第十二章图形用户界面...................................................................................................255 §12.1用户界面设计概述 ............................................................................................255 12.1.1 用户界面设计原则 ...................................................................................255 12.1.2 用户界面设计内容 ...................................................................................256 §12.2 Java程序的用户界面设计 .................................................................................257 12.2.1 Java程序的用户界面 ................................................................................257 12.2.2 GUI系统的组成........................................................................................257 12.2.3 AWT和 Swing组件 ..................................................................................258 §12.3 Swing概述 .........................................................................................................258 12.3.1 Swing组件 ................................................................................................258 12.3.2 Swing的 M-UI设计模式 .........................................................................259 12.3.3 Swing的事件处理模式.............................................................................260 12.3.4 一个简单的 GUI程序..............................................................................262 - vi - 12.3.5 类 JComponent简介.................................................................................265 §12.4 Swing顶层容器 .................................................................................................268 12.4.1 画框的使用 ...............................................................................................268 12.4.2 对话框的使用 ...........................................................................................269 §12.5 Swing中间容器 .................................................................................................272 12.5.1 分隔窗格的使用 .......................................................................................272 12.5.2 滚动窗格的使用 .......................................................................................273 12.5.3 带标签窗格的使用 ...................................................................................278 12.5.4 工具条的使用 ...........................................................................................280 §12.6 Swing原子控件 .................................................................................................281 12.6.1 标签的使用 ...............................................................................................281 12.6.2 按钮的使用 ...............................................................................................283 12.6.3 检查框的使用 ...........................................................................................286 12.6.4 广播按钮的使用 .......................................................................................289 12.6.5 组合框的使用 ...........................................................................................290 12.6.6 列表的使用 ...............................................................................................294 12.6.7 文本控件的使用 .......................................................................................300 12.6.8 表格的使用 ...............................................................................................307 12.6.9 菜单的使用 ...............................................................................................311 §12.7 Swing的布局管理 .............................................................................................316 12.7.1 布局管理器概述 .......................................................................................316 12.7.2 顺序布局管理器 .......................................................................................317 12.7.3 边界布局管理器 .......................................................................................318 12.7.4 网格布局管理器 .......................................................................................318 12.7.5 网格包布局管理器 ...................................................................................319 12.7.6 盒式布局管理器 .......................................................................................321 12.7.7 卡片布局管理器 .......................................................................................322 12.7.8 组件的绝对定位 .......................................................................................323 12.7.9 边框的使用 ...............................................................................................324 §12.8编写小应用程序 ................................................................................................328 12.8.1 Applet的特点 ............................................................................................328 12.8.2 Applet的编程模式 ....................................................................................328 12.8.3 Applet的编程举例 ....................................................................................330 内容小结.......................................................................................................................332 思考与练习...................................................................................................................332 上机实习题...................................................................................................................333 第十三章数据库编程初步...............................................................................................334 §13.1关系数据库与 SQL简介 ..................................................................................334 13.1.1 关系数据库的基本概念 ...........................................................................334 13.1.2 创建关系数据库举例 ...............................................................................334 13.1.3 SQL简介 ...................................................................................................337 §13.2 JDBC结构与原理..............................................................................................341 13.2.1 数据库应用的多层结构 ...........................................................................341 13.2.2 JDBC的结构.............................................................................................342 13.2.3 建立使用 JDBC的运行环境 ...................................................................343 §13.3 JDBC应用入门..................................................................................................344 13.3.1 使用 JDBC的编程模式 ...........................................................................344 13.3.2 Java与 SQL间的数据类型映射 ..............................................................347 13.3.3 使用数据表的元信息 ...............................................................................349 13.3.4 封装与数据库访问有关的操作 ...............................................................350 §13.4数据库应用程序举例 ........................................................................................353 - vii - 13.4.1 需求分析 ...................................................................................................353 13.4.2 系统设计 ...................................................................................................354 13.4.3 编码实现 ...................................................................................................356 内容小结.......................................................................................................................367 思考与练习...................................................................................................................368 上机实习题...................................................................................................................369 第十四章多线程编程.......................................................................................................370 §14.1线程的基本概念 ................................................................................................370 14.1.1 什么是线程? ...........................................................................................370 14.1.2 Java程序中的线程 ....................................................................................370 §14.2线程生存期与线程调度 ....................................................................................371 14.2.1 创建线程 ...................................................................................................371 14.2.2 Java程序的主线程 ....................................................................................373 14.2.3 线程的生存期 ...........................................................................................373 14.2.4 使用 yield()方法 .......................................................................................374 14.2.5 优先级与线程调度 ...................................................................................375 14.2.6 线程组 .......................................................................................................377 14.2.7 守护线程 ...................................................................................................378 §14.3资源共享与线程同步 ........................................................................................379 14.3.1 线程安全性 ...............................................................................................379 14.3.2 同步代码段与锁 .......................................................................................380 14.3.3 设计线程安全的应用程序 .......................................................................382 §14.4其他线程通信方式 ............................................................................................383 14.4.1 使用 sleep()方法.......................................................................................383 14.4.2 使用 join()方法.........................................................................................383 14.4.3 使用 wait()/notify()/notifyAll()方法.........................................................384 14.4.4 使用 I/O操作 ...........................................................................................386 14.4.5 不主张使用的方法 ...................................................................................386 §14.5使用定时器 ........................................................................................................387 14.5.1 通用定时器 ...............................................................................................387 14.5.2 Swing专用定时器.....................................................................................389 §14.6高级多线程设计 ................................................................................................389 14.6.1 并发模型 ...................................................................................................389 14.6.2 互斥问题 ...................................................................................................391 14.6.3 生产者∕消费者问题 ...............................................................................393 内容小结.......................................................................................................................396 思考与练习...................................................................................................................396 上机实习题...................................................................................................................397 小课题:资源池与线程池...........................................................................................397 第十五章网络通信编程...................................................................................................399 §15.1网络通信的基本概念 ........................................................................................399 15.1.1 通信协议 ...................................................................................................399 15.1.2 TCP与 UDP ..............................................................................................401 15.1.3 端口...........................................................................................................401 15.1.4 Java对网络通信的支持 ............................................................................402 §15.2基于 URL的通信..............................................................................................403 15.2.1 使用 URL对象.........................................................................................403 15.2.2 使用 URL连接.........................................................................................405 §15.3基于 TCP的通信 ..............................................................................................407 15.3.1 指定主机 ...................................................................................................407 15.3.2 基于 socket的 C/S编程...........................................................................408 - viii - 15.3.3 多线程服务程序 .......................................................................................411 §15.4典型的因特网应用 ............................................................................................413 15.4.1 一个简单的端口扫描程序 .......................................................................413 15.4.2 一个简单的 HTTP服务程序...................................................................414 15.4.3 一个简单的 Telnet客户程序...................................................................415 15.4.4 一个简单的 SMTP客户程序 ..................................................................417 §15.5基于 UDP的通信..............................................................................................418 15.5.1 单播通信 ...................................................................................................418 15.5.2 多播通信 ...................................................................................................422 内容小结.......................................................................................................................424 思考与练习...................................................................................................................424 上机实习题...................................................................................................................425 第十六章结束语...............................................................................................................426 §16.1设计原则 ............................................................................................................426 16.1.1 设计原则与设计模式 ...............................................................................426 16.1.2 B. Meyer的设计原则................................................................................426 16.1.3 R. Martin的设计原则 ...............................................................................427 §16.2设计模式 ............................................................................................................428 16.2.1 什么是模式 ...............................................................................................428 16.2.2 GoF设计模式 ............................................................................................429 16.2.4 POSA设计模式.........................................................................................431 16.2.5 反模式 .......................................................................................................431 §16.3分布式对象技术 ................................................................................................432 16.3.1 进程内通信与进程间通信 .......................................................................432 16.3.2 实现网络通信的途径 ...............................................................................432 16.3.3 分布式对象系统 .......................................................................................432 内容小结.......................................................................................................................433 思考与练习...................................................................................................................433 上机实习题...................................................................................................................434 ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: Java 程序设计 教程
 输入关键字,在本站1000多万海量源码库中尽情搜索: