关于我们
书单推荐
新书推荐
|
Java语言程序设计(基础篇)(英文版·原书第11版)
本书是Java语言的经典教材,多年来畅销不衰。本书全面整合了Java 8的特性,采用“基础优先,问题驱动”的教学方式,循序渐进地介绍了程序设计基础、解决问题的方法、面向对象程序设计、图形用户界面设计、异常处理、I/O和递归等内容。此外,本书还全面且深入地覆盖了一些高级主题,包括算法和数据结构、多线程、网络、国际化、高级GUI等内容。
第1章 计算机、程序和Java概述 1
1.1 引言 2 1.2 什么是计算机 2 1.3 编程语言 7 1.4 操作系统 9 1.5 Java、万维网以及其他 10 1.6 Java语言规范、API、JDK、JRE和IDE 11 1.7 一个简单的Java程序 12 1.8 创建、编译和执行Java程序 15 1.9 程序设计风格和文档 18 1.10 程序设计错误 20 1.11 使用NetBeans开发Java程序 23 1.12 使用Eclipse开发Java程序 25 第2章 基本程序设计 33 2.1 引言 34 2.2 编写简单的程序 34 2.3 从控制台读取输入 37 2.4 标识符 40 2.5 变量 40 2.6 赋值语句和赋值表达式 42 2.7 命名常量 43 2.8 命名习惯 44 2.9 数值数据类型和操作 45 2.10 数值型字面值 48 2.11 表达式求值以及操作符优先级 50 2.12 示例学习:显示当前时间 52 2.13 增强赋值操作符 54 2.14 自增和自减操作符 55 2.15 数值类型转换 57 2.16 软件开发过程 59 2.17 示例学习:整钱兑零 63 2.18 常见错误和陷阱 65 第3章 选择 75 3.1 引言 76 3.2 boolean数据类型 76 3.3 if语句 78 3.4 双分支if-else语句 80 3.5 嵌套的if语句和多分支if-else语句 81 3.6 常见错误和陷阱 83 3.7 产生随机数 87 3.8 示例学习:计算身体质量指数 89 3.9 示例学习:计算税率 90 3.10 逻辑操作符 93 3.11 示例学习:判定闰年 97 3.12 示例学习:彩票 98 3.13 switch语句 100 3.14 条件操作 103 3.15 操作符的优先级和结合规则 104 3.16 调试 106 第4章 数学函数、字符和字符串 119 4.1 引言 120 4.2 常用数学函数 120 4.3 字符数据类型和操作 125 4.4 String类型 130 4.5 示例学习 139 4.6 格式化控制台输出 145 第5章 循环 159 5.1 引言 160 5.2 while循环 160 5.3 示例学习:猜数字 163 5.4 循环设计策略 166 5.5 使用用户确认或者标记值控制循环 168 5.6 do-while循环 170 5.7 for循环 173 5.8 采用哪种循环 176 5.9 嵌套循环 178 5.10 最小化数值错误 180 5.11 示例学习 182 5.12 关键字break和continue 186 5.13 示例学习:判断回文 189 5.14 示例学习:显示素数 191 第6章 方法 205 6.1 引言 206 6.2 定义方法 206 6.3 调用方法 208 6.4 void方法与返回值方法 211 6.5 按值传参 214 6.6 模块化代码 217 6.7 示例学习:将十六进制数转换为十进制数 219 6.8 重载方法 221 6.9 变量的作用域 224 6.10 示例学习:生成随机字符 225 6.11 方法抽象和逐步求精 227 第7章 一维数组 247 7.1 引言 248 7.2 数组的基础知识 248 7.3 示例学习:分析数字 255 7.4 示例学习:一副牌 256 7.5 复制数组 258 7.6 将数组传递给方法 259 7.7 方法返回数组 262 7.8 示例学习:统计每个字母出现的次数 263 7.9 可变长参数列表 266 7.10 数组的查找 267 7.11 数组的排序 271 7.12 Arrays类 272 7.13 命令行参数 274 第8章 多维数组 289 8.1 引言 290 8.2 二维数组基础 290 8.3 处理二维数组 293 8.4 将二维数组传递给方法 295 8.5 示例学习:多选题测验评分 296 8.6 示例学习:找出距离最近的点对 298 8.7 示例学习:数独 300 8.8 多维数组 303 第9章 对象和类 323 9.1 引言 324 9.2 为对象定义类 324 9.3 示例:定义类和创建对象 326 9.4 使用构造方法构造对象 331 9.5 通过引用变量访问对象 332 9.6 使用Java库中的类 336 9.7 静态变量、常量和方法 339 9.8 可见性修饰符 344 9.9 数据域封装 346 9.10 向方法传递对象参数 349 9.11 对象数组 353 9.12 不可变对象和类 355 9.13 变量的作用域 357 9.14 this引用 358 第10章 面向对象思考 367 10.1 引言 368 10.2 类的抽象和封装 368 10.3 面向对象的思想 372 10.4 类的关系 375 10.5 示例学习:设计Course类 378 10.6 示例学习:设计栈类 380 10.7 将基本数据类型值作为对象处理 382 10.8 基本类型和包装类类型之间的自动转换 385 10.9 BigInteger和BigDecimal类 386 10.10 String类 388 10.11 StringBuilder类和StringBuffer类 394 第11章 继承和多态 411 11.1 引言 412 11.2 父类和子类 412 11.3 使用super关键字 418 11.4 方法重写 421 11.5 方法重写与重载 422 11.6 Object类及其toString()方法 424 11.7 多态 425 11.8 动态绑定 425 11.9 对象转换和instanceof操作符 429 11.10 Object类的equals方法 433 11.11 ArrayList类 434 11.12 关于列表的一些有用方法 440 11.13 示例学习:自定义栈类 441 11.14 protected数据和方法 442 11.15 防止继承和重写 445 第12章 异常处理和文本I/O 453 12.1 引言 454 12.2 异常处理概述 454 12.3 异常类型 459 12.4 关于异常处理的更多讨论 462 12.5 finally子句 470 12.6 何时使用异常 471 12.7 重新抛出异常 472 12.8 链式异常 473 12.9 创建自定义异常类 474 12.10 File类 477 12.11 文件输入和输出 480 12.12 从Web上读取数据 486 12.13 示例学习:Web爬虫 488 第13章 抽象类和接口 499 13.1 引言 500 13.2 抽象类 500 13.3 示例学习:抽象的Number类 505 13.4 示例学习:Calendar和GregorianCalendar 507 13.5 接口 510 13.6 Comparable接口 513 13.7 Cloneable接口 518 13.8 接口与抽象类 523 13.9 示例学习:Rational类 526 13.10 类的设计原则 531 第14章 JavaFX基础 541 14.1 引言 542 14.2 JavaFX与Swing以及AWT的比较 542 14.3 JavaFX程序的基本结构 542 14.4 面板、组、UI组件以及形状 545 14.5 属性绑定 548 14.6 结点的共同属性和方法 551 14.7 Color类 553 14.8 Font类 554 14.9 Image和ImageView类 556 14.10 布局面板和组 558 14.11 形状 567 14.12 示例学习:ClockPane类 580 第15章 事件驱动编程和动画 593 15.1 引言 594 15.2 事件和事件源 596 15.3 注册处理器和处理事件 597 15.4 内部类 601 15.5 匿名内部类处理器 602 15.6 使用lambda表达式简化事件处理 605 15.7 示例学习:贷款计算器 609 15.8 鼠标事件 611 15.9 键盘事件 613 15.10 可观察对象的监听器 616 15.11 动画 618 15.12 示例学习:弹球 626 15.13 示例学习:美国地图 630 第16章 JavaFX UI组件和多媒体 643 16.1 引言 644 16.2 Labeled和Label 644 16.3 Button 646 16.4 CheckBox 648 16.5 RadioButton 651 16.6 TextField 654 16.7 TextArea 655 16.8 ComboBox 659 16.9 ListView 662 16.10 ScrollBar 665 16.11 Slider 668 16.12 示例学习:开发一个井字游戏 671 16.13 视频和音频 676 16.14 示例学习:国旗和国歌 679 第17章 二进制 I/O 691 17.1 引言 692 17.2 在Java中如何处理文本I/O 692 17.3 文本I/O与二进制I/O 693 17.4 二进制I/O类 694 17.5 示例学习:复制文件 704 17.6 对象I/O 706 17.7 随机访问文件 711 第18章 递归 719 18.1 引言 720 18.2 示例学习:计算阶乘 720 18.3 示例学习:计算斐波那契数 723 18.4 使用递归解决问题 726 18.5 递归辅助方法 728 18.6 示例学习:获取目录的大小 731 18.7 示例学习:汉诺塔 733 18.8 示例学习:分形 736 18.9 递归与迭代 740 18.10 尾递归 740 附录A Java关键字 751 附录B ASCII字符集 752 附录C 操作符优先级表 754 附录D Java修饰符 756 附录E 特殊浮点值 758 附录F 数系 759 附录G 位操作符 763 附录H 正则表达式 764 附录I 枚举类型 769 contentS chapter 1 Introduction to computers, Programs, and Java. 1 1.1 Introduction 2 1.2 What Is a Computer? 2 1.3 Programming Languages 7 1.4 Operating Systems 9 1.5 Java, the World Wide Web, and Beyond 10 1.6 The Java Language Specification, API, JDK, JRE, and IDE 11 1.7 A Simple Java Program 12 1.8 Creating, Compiling, and Executing a Java Program 15 1.9 Programming Style and Documentation 18 1.10 Programming Errors 20 1.11 Developing Java Programs Using NetBeans 23 1.12 Developing Java Programs Using Eclipse 25 chapter 2 elementary Programming 33 2.1 Introduction 34 2.2 Writing a Simple Program 34 2.3 Reading Input from the Console 37 2.4 Identifiers 40 2.5 Variables 40 2.6 Assignment Statements and Assignment Expressions 42 2.7 Named Constants 43 2.8 Naming Conventions 44 2.9 Numeric Data Types and Operations 45 2.10 Numeric Literals 48 2.11 Evaluating Expressions and Operator Precedence 50 2.12 Case Study: Displaying the Current Time 52 2.13 Augmented Assignment Operators 54 2.14 Increment and Decrement Operators 55 2.15 Numeric Type Conversions 57 2.16 Software Development Process 59 2.17 Case Study: Counting Monetary Units 63 2.18 Common Errors and Pitfalls 65 chapter 3 Selections 75 3.1 Introduction 76 3.2 boolean Data Type 76 3.3 if Statements 78 3.4 Two-Way if-else Statements 80 3.5 Nested if and Multi-Way if-else Statements 81 3.6 Common Errors and Pitfalls 83 3.7 Generating Random Numbers 87 3.8 Case Study: Computing Body Mass Index 89 3.9 Case Study: Computing Taxes 90 3.10 Logical Operators 93 3.11 Case Study: Determining Leap Year 97 3.12 Case Study: Lottery 98 3.13 switch Statements 100 3.14 Conditional Operators 103 3.15 Operator Precedence and Associativity 104 3.16 Debugging 106 chapter 4 mathematical functions, characters, and Strings 119 4.1 Introduction 120 4.2 Common Mathematical Functions 120 4.3 Character Data Type and Operations 125 4.4 The String Type 130 4.5 Case Studies 139 4.6 Formatting Console Output 145 chapter 5 Loops 159 5.1 Introduction 160 5.2 The while Loop 160 5.3 Case Study: Guessing Numbers 163 5.4 Loop Design Strategies 166 5.5 Controlling a Loop with User Confirmation or a Sentinel Value 168 5.6 The do-while Loop 170 5.7 The for Loop 173 5.8 Which Loop to Use? 176 5.9 Nested Loops 178 5.10 Minimizing Numeric Errors 180 5.11 Case Studies 182 5.12 Keywords break and continue 186 5.13 Case Study: Checking Palindromes 189 5.14 Case Study: Displaying Prime Numbers 191 chapter 6 methods 205 6.1 Introduction 206 6.2 Defining a Method 206 6.3 Calling a Method 208 6.4 void vs. Value-Returning Methods 211 6.5 Passing Parameters by Values 214 6.6 Modularizing Code 217 6.7 Case Study: Converting Hexadecimals to Decimals 219 6.8 Overloading Methods 221 6.9 The Scope of Variables 224 6.10 Case Study: Generating Random Characters 225 6.11 Method Abstraction and Stepwise Refinement 227 chapter 7 Single-dimensional arrays 247 7.1 Introduction 248 7.2 Array Basics 248 7.3 Case Study: Analyzing Numbers 255 7.4 Case Study: Deck of Cards 256 7.5 Copying Arrays 258 7.6 Passing Arrays to Methods 259 7.7 Returning an Array from a Method 262 7.8 Case Study: Counting the Occurrences of Each Letter 263 7.9 Variable-Length Argument Lists 266 7.10 Searching Arrays 267 7.11 Sorting Arrays 271 7.12 The Arrays Class 272 7.13 Command-Line Arguments 274 chapter 8 multidimensional arrays 289 8.1 Introduction 290 8.2 Two-Dimensional Array Basics 290 8.3 Processing Two-Dimensional Arrays 293 8.4 Passing Two-Dimensional Arrays to Methods 295 8.5 Case Study: Grading a Multiple-Choice Test 296 8.6 Case Study: Finding the Closest Pair 298 8.7 Case Study: Sudoku 300 8.8 Multidimensional Arrays 303 chapter 9 objects and classes 323 9.1 Introduction 324 9.2 Defining Classes for Objects 324 9.3 Example: Defining Classes and Creating Objects 326 9.4 Constructing Objects Using Constructors 331 9.5 Accessing Objects via Reference Variables 332 9.6 Using Classes from the Java Library 336 9.7 Static Variables, Constants, and Methods 339 9.8 Visibility Modifiers 344 9.9 Data Field Encapsulation 346 9.10 Passing Objects to Methods 349 9.11 Array of Objects 353 9.12 Immutable Objects and Classes 355 9.13 The Scope of Variables 357 9.14 The this Reference 358 chapter 10 object-oriented thinking 367 10.1 Introduction 368 10.2 Class Abstraction and Encapsulation 368 10.3 Thinking in Objects 372 10.4 Class Relationships 375 10.5 Case Study: Designing the Course Class 378 10.6 Case Study: Designing a Class for Stacks 380 10.7 Processing Primitive Data Type Values as Objects 382 10.8 Automatic Conversion between Primitive Types and Wrapper Class Types 385 10.9 The BigInteger and BigDecimal Classes 386 10.10 The String Class 388 10.11 The StringBuilder and StringBuffer Classes 394 chapter 11 Inheritance and Polymorphism 411 11.1 Introduction 412 11.2 Superclasses and Subclasses 412 11.3 Using the super Keyword 418 11.4 Overriding Methods 421 11.5 Overriding vs. Overloading 422 11.6 The Object Class and Its toString() Method 424 11.7 Polymorphism 425 11.8 Dynamic Binding 425 11.9 Casting Objects and the instanceof Operator 429 11.10 The Object’s equals Method 433 11.11 The ArrayList Class 434 11.12 Useful Methods for Lists 440 11.13 Case Study: A Custom Stack Class 441 11.14 The protected Data and Methods 442 11.15 Preventing Extending and Overriding 445 chapter 12 exception handlingand text I/o 453 12.1 Introduction 454 12.2 Exception-Handling Overview 454 12.3 Exception Types 459 12.4 More on Exception Handling 462 12.5 The finally Clause 470 12.6 When to Use Exceptions 471 12.7 Rethrowing Exceptions 472 12.8 Chained Exceptions 473 12.9 Defining Custom Exception Classes 474 12.10 The File Class 477 12.11 File Input and Output 480 12.12 Reading Data from the Web 486 12.13 Case Study: Web Crawler 488 chapter 13 abstract classes and Interfaces 499 13.1 Introduction 500 13.2 Abstract Classes 500 13.3 Case Study: the Abstract Number Class 505 13.4 Case Study: Calendar and GregorianCalendar 507 13.5 Interfaces 510 13.6 The Comparable Interface 513 13.7 The Cloneable Interface 518 13.8 Interfaces vs. Abstract Classes 523 13.9 Case Study: The Rational Class 526 13.10 Class-Design Guidelines 531 chapter 14 JavafX Basics 541 14.1 Introduction 542 14.2 JavaFX vs Swing and AWT 542 14.3 The Basic Structure of a JavaFX Program 542 14.4 Panes, Groups, UI Controls, and Shapes 545 14.5 Property Binding 548 14.6 Common Properties and Methods for Nodes 551 14.7 The Color Class 553 14.8 The Font Class 554 14.9 The Image and ImageView Classes 556 14.10 Layout Panes and Groups 558 14.11 Shapes 567 14.12 Case Study: The ClockPane Class 580 chapter 15 event-driven Programmingand animations 593 15.1 Introduction 594 15.2 Events and Event Sources 596 15.3 Registering Handlers and Handling Events 597 15.4 Inner Classes 601 15.5 Anonymous Inner-Class Handlers 602 15.6 Simplifying Event Handling Using Lambda Expressions 605 15.7 Case Study: Loan Calculator 609 15.8 Mouse Events 611 15.9 Key Events 613 15.10 Listeners for Observable Objects 616 15.11 Animation 618 15.12 Case Study: Bouncing Ball 626 15.13 Case Study: US Map 630 chapter 16 JavafX uI controls and multimedia 643 16.1 Introduction 644 16.2 Labeled and Label 644 16.3 Button 646 16.4 CheckBox 648 16.5 RadioButton 651 16.6 TextField 654 16.7 TextArea 655 16.8 ComboBox 659 16.9 ListView 662 16.10 ScrollBar 665 16.11 Slider 668 16.12 Case Study: Developing a Tic-Tac-Toe Game 671 16.13 Video and Audio 676 16.14 Case Study: National Flags and Anthems 679 chapter 17 Binary I/o 691 17.1 Introduction 692 17.2 How Is Text I/O Handled in Java? 692 17.3 Text I/O vs. Binary I/O 693 17.4 Binary I/O Classes 694 17.5 Case Study: Copying Files 704 17.6 Object I/O 706 17.7 Random-Access Files 711 chapter 18 recursion 719 18.1 Introduction 720 18.2 Case Study: Computing Factorials 720 18.3 Case Study: Computing Fibonacci Numbers 723 18.4 Problem Solving Using Recursion 726 18.5 Recursive Helper Methods 728 18.6 Case Study: Finding the Directory Size 731 18.7 Case Study: Tower of Hanoi 733 18.8 Case Study: Fractals 736 18.9 Recursion vs. Iteration 740 18.10 Tail Recursion 740 Appendix a Java Keywords 751 Appendix B the aScII character Set 752 Appendix c operator Precedence chart 754 Appendix d Java modifiers 756 Appendix e Special floating-Point values 758 Appendix f number Systems 759 Appendix g Bitwise operations 763 Appendix h regular expressions 764 Appendix I enumerated types 769
你还可能感兴趣
我要评论
|