本书专为没有编程经验的学生编写,是一本使用Java语言进行面向对象编程的入门书籍。作者以对象的使用为起点,逐步讲解了如何编写对象和理解继承,面向对象设计的重要性,直至如何独立建立一个面向对象的系统。这种教学形式有助于学生在对象模型方面打下坚实的基础。\r\n 本书覆盖了Java语言的所有重要方面,包括使用Java标准库中的类,以及作者定义的比较容易理解和消化的类。此外,书中还专门介绍了Java语言的高级方面,包括GUI、applet。输入/输出以及基本的数据结构,使学生在编写Java程序时可以使用多种工具。\r\n 本书特点\r\n·逐步介绍Java语言类的使用,书的荫几章介绍输入/输出以及一组作者定义的工具以帮助刚开始学习Java的学生。第19章使用来自java.io包的类,重点介绍Java的输入和输出\r\n·第11章让学生有机会综合所学到的概念和技巧,从构建类开始设计一个task organizsr程序\r\n·第12章详细介绍继承的概念,让学生在准备学习其他高级的面向对象概念的同时,理解和掌握对象模型中继承的重要性\r\n·第20章介绍applet的创建和使用\r\n·第五部分讨论面向对象的设计,包括方法学以及案例分析,引导学生遍历开发过程的各个阶段。
Part 1 Using Objects\r\n\r\nProgramming and the Java Language\r\n1.1 Programs and Programming \r\n1.2 Algorithms \r\n1.3 High-Level Languages and Programs \r\n1.4 A Simple Computer \r\n1.5 Machine Code \r\n1.6 Files and the Filing System \r\n1.7 The World Wide Web \r\n1.8 The Java Programming Language \r\n1.9 Getting Started with Java \r\n1.10 A First Java Program \r\n1.11 The pti nt and println Methods \r\n1.12 How This Book Is Arranged \r\n1.13 Key Points in Chapter 1 \r\n1.14 Exercises \r\n\r\n2 Object Orientation \r\n\r\n2.1 Objects and Classes \r\n2.2 Software Objects \r\n2.3 More about Single Objects \r\n2.4 An Object-Oriented Program\r\n2.5 Types \r\n2.6 Classes and Instances Revisited\r\n2.7 Key Points in Chapter 2 \r\n2.8 Exercises \r\n\r\n3 Declaring Objects and Calling Methods \r\n\r\n3.1 Program Structure \r\n3.2 The class Person \r\n3.3 A Program to Manipulate a Person \r\n3.4 The i mp0rt Statement \r\n3.5 Declaring Objects \r\n3.6 Using Methods to Set the Attributes of Objects \r\n3.7 Using Methods to Extract Object Attributes \r\n3.8 Using Constants in Java \r\n3.9 Using Objects and Methods \r\n3.10 A Variety of Methods \r\n3.11 Constructors Revisited \r\n3.12 Input to a Program (Optional) \r\n3.13 Key Points in Chapter 3 \r\n3.14 Exercises \r\n\r\n4 Selecting Among Alternatives \r\n\r\n4.1 Reading Values from the Keyboard \r\n4.2 More on Integer Variables \r\n4.3 Type Checking \r\n4.4 Making Decisions\r\n4.5 Selection Statements in Java \r\n4.5.1 Statements \r\n4.5.2 Relational Operators and Boolean Expressions \r\n4.6 The Boolean Type \r\n4.7 The switch Statement \r\n4.8 Testing a New Class \r\n4.9 Key Points in Chapter 4 \r\n4.10 Exercises \r\n\r\n5 Repetition \r\n\r\n5.1 Repetition as a Basic Control Structure \r\n5.2 Looping a Predetermined Number of Times: The for Statement \r\n5.3 Looping an Indeterminate Number of Times: The whi 1 e Statement \r\n5.4 Stopping in the Middle of an Iteration \r\n5.5 for Loops and while Loops \r\n5.6 Nested Loops \r\n5.7 Boolean Expressions for Loops \r\n5.8 Testing at the End of the Loop\r\n5.9 Other Java Loop Features \r\n5.10 Key Points in Chapter 5 \r\n5.11 Exercises \r\n\r\n6 Basic Java Data Types \r\n\r\n6.1 Objects and Basic Data Types \r\n6.1.1 Declaration \r\n6.1.2 Setting a Value \r\n6.1.3 Obtaining a Value \r\n6.1.4 Arguments to Methods \r\n6.2 The int Data Type \r\n6.3 Other Whole Number Data Types in Java (Optional) \r\n6.4 Floating-Point Data Types \r\n6.5 The b001 ean Data Type \r\n6.6 The char Data Type \r\n6.7 The String Class \r\n6.8 Methods for the String Class \r\n6.9 Wrapper Classes (Optional) \r\n6.10 Key Points in Chapter 6 \r\n6.11 Exercises \r\n\r\nPart 2 Writing Objects\r\n\r\n7 A Simple Class \r\n\r\n7.1 What We Are Trying to Achieve \r\n7.2 Providing the Person Class \r\n7.3 Methods for the Person Class \r\n7.4 Actual and Formal Arguments \r\n7.5 Modes of Argument Passing \r\n7.6 Return Values \r\n7.7 Lexical Conventions within a Class \r\n7.8 Key Points in Chapter 7 \r\n7.9 Exercises \r\n\r\n8 More on the Simple Class \r\n\r\n8.1 Constructor Methods \r\n8.2 Overloading \r\n8.3 Class Constants \r\n8.4 Class Variables \r\n8.5 Private Methods \r\n8.6 Class or Static Methods \r\n8.7 Revisiting the Main Class \r\n8.8 Packages and Directories \r\n8.8.1 The i mp0rt Statement \r\n8.9 Scope and Visibility \r\n8.9.1 Intraclass Visibility \r\n8.9.2 Use of this \r\n8.9.3 Interclass Visibility \r\n8.10 Key Points in Chapter 8\r\n8.11 Exercises \r\n\r\n9 Arrays \r\n\r\n9.1 Collections of Elements \r\n9.2 Arrays of Objects \r\n9.3 Searching an Array\r\n9.4 Binary Search \r\n9.5 Sorting an Array \r\n9.6 Arrays as Arguments \r\n9.7 Multidimensional Arrays \r\n9.8 Nonrectangular Arrays (Optional) \r\n9.9 Key Points in Chapter 9 \r\n9.10 Exercises \r\n\r\n10 Objects within Objects \r\n\r\n10.1 What We Are Trying to Achieve \r\n10.2 Writing the 0urDate Class \r\n10.3 Using the OurDate Class \r\n10.4 Objects as Arguments \r\n10.5 Multiple References to the Same Object \r\n10.6 Objects as Arguments and Return Values: Call by Reference \r\n10.6.1 Changing the Contents of the Formal and Actual Arguments\r\n10.7 Hiding References to Other Objects \r\n10.8 Key Points in Chapter 10 \r\n10.9 Exercises \r\n\r\n11 Putting Objects to Work \r\n\r\n11.1 A Task Organizer Program \r\n11.2 A Priority Queue Class \r\n11.3 Implementing a Priority Queue with an Array \r\n11.4 Alternative Implementations of PriorityQueue (Optional) \r\n11.5 Testing the PriorityQueue Class \r\n11.6 Using the PriorityQueue Class \r\n11.7 Outstanding Issues \r\n11.8 Key Points in Chapter 11 \r\n11.9 Exercises \r\n\r\nPart 3 Advanced Objects\r\n\r\n12 Introduction to Inheritance \r\n\r\n12.1 Motivation \r\n12.1.1 Data Modeling \r\n12.1.2 Programming \r\n12.2 What's the Difference? \r\n12.3 Overriding Inherited Methods \r\n12.4 Access Rights and Subclasses \r\n12.5 Airplane Reservations: An Example \r\n12.6 Key Points in Chapter 12 \r\n12.7 Exercises \r\n\r\n13 Class and Method Polymorphism \r\n\r\n13.1 Person and Student: An Example \r\n13.2 Constructor Methods and Inheritance \r\n13.2.1 Constructor Chaining \r\n13.3 Multiple Levels of Inheritance: The Inheritance Hierarchy \r\n13.4 The Class Object \r\n13.5 Polymorphism \r\n13.6 Polymorphism and Heterogeneous Collections \r\n13.6.1 Dynamic Method Binding (Late Binding) \r\n13.7 Calling Overridden Methods \r\n13.8 Methods in Derived Classes \r\n13.9 Key Points in Chapter 13 \r\n13.10 Exercises \r\n\r\n14 Abstract Classes and Interfaces \r\n\r\n14.1 Abstract Classes \r\n14.2 Polymorphism \r\n14.3 Interfaces \r\n14.4 Key Points in Chapter 14 \r\n14.5 Exercises \r\n\r\n15 Throwing and Catching Exceptions \r\n\r\n15.1 Motivation: Robust Programs \r\n15.2 Defining a New Exception \r\n15.3 Throwing an Exception \r\n15.4 Catching an Exception \r\n15.4.1 The finally Clause (Optional) \r\n15.5 Key Points in Chapter 15 \r\n15.6 Exercises \r\n\r\n16 Graphics and the Abstract Windowing Toolkit \r\n\r\n16.1 Graphical User Interfaces \r\n16.2 A Simple Program with a Graphical Interface \r\n16.3 Writing the Chapterl6n0 Class \r\n16.3.1 The Constructor for the Chapterl6n0 Class \r\n16.3.2 Other Layout Managers \r\n16.3.3 The main Method for the Chapterl6n0 Class \r\n16.3.4 The actionPerformed Method of the Chapterl6nO Class \r\n16.3.5 The windowClosing Method of the Chapterl6n0 Class \r\n16.4 Writing the CanvasO Class \r\n16.5 Writing Text on the Canvas\r\n16.6 Animating the Simple Graphics Program \r\n16.7 Input of Character Strings in a Graphical Interface \r\n16.7.1 Setting Up the Picture \r\n16.7.2 Getting a String from a WextField \r\n16.7.3 Drawing the Thermometer \r\n16.8 Menus, Files, and Images (Optional) \r\n16.8.1 Setting Up Menus \r\n16.8.2 Selecting a File \r\n16.8.3 Displaying an Image \r\n16.8.4 Tracking the Mouse \r\n16.9 Key Points in Chapter 16 \r\n16.10 Exercises \r\n\r\nPart 4 Advanced Java\r\n\r\n17 Linked Data Structures \r\n\r\n17.1 Linear and Linked Data Structures \r\n17.2 Implementing a Priority Queue Using a Linked Data Structure \r\n17.3 Methods for the PriorityOueue Class \r\n17.3.1 The length Method \r\n17.3.2 The first Method \r\n17.3.3 The remove Method\r\n17.4 The insert Method \r\n17.5 Deletion from a Linked Data Structure (Optional) \r\n17.6 Doubly Linked Lists (Optional) \r\n17.7 Using Linked Data Structures \r\n17.8 Key Points in Chapter 17 \r\n17.9 Exercises \r\n\r\n18 Recursion and Binary Trees \r\n\r\n18.1 Recursion \r\n18.2 Solving the Towers of Hanoi Problem \r\n18.2.1 A Recursive Solution to the Towers of Hanoi Problem \r\n18.2.2 An Iterative Solution to the Towers of Hanoi Problem \r\n18.3 Binary Trees \r\n18.3.1 Searching and Updating a Binary Tree \r\n18.3.2 Writing the Code for the Binary Tree \r\n18.3.3 Adding a Word Occurrence to the Lexicon \r\n18.3.4 Outputting the Lexicon Information \r\n18.4 Key Points in Chapter 18 \r\n18.5 Exercises \r\n\r\n19 Input and Output in Java \r\n\r\n19.1 Input and Output Systems \r\n19.2 The Java Classes for Input and Output \r\n19.3 The PrintStream Class and System.out \r\n19.3.1 Output Redirection \r\n19.4 The BufferedReader Class and System. in \r\n19.4.1 Tokenizing an Input Line \r\n19.4.2 Converting Strings to Numeric Values \r\n19.4.3 Redirecting Input \r\n19.5 Files and File Handling \r\n19.6 Reading and Writing Files \r\n19.6.1 Writing to a File \r\n19.6.2 Reading from a File \r\n19.7 Binary Files (Optional) \r\n19.8 Random Access Files (Optional) \r\n19.9 Accessing Other Computers (Optional) \r\n19.10 Key Points in Chapter 19 \r\n19.11 Exercises \r\n\r\n20 Creating and Using Applets \r\n\r\n20.1 Creating Applets \r\n20.2 Using Applets \r\n20.3 More about Applets \r\n20.4 A Useful Applet \r\n20.4.1 ThereadIndex Method \r\n20.4.2 The act i0nPerf0rmed Method \r\n20.5 Security Aspects of the Use of Applets \r\n20.6 Key Points in Chapter 20 \r\n20.7 Exercises \r\n\r\n21 Other Features of Java \r\n\r\n21.1 Vectors and Other Java Data Structures \r\n21.1.1 The Vector Class \r\n21.1.2 The Hashtable Class \r\n21.2 Strings and StringBuffers \r\n21.3 Run-Time Type Information (Optional) \r\n21.4 Threads (Optional) \r\n21.4.1 Synchronizing Threads \r\n21.5 Key Points in Chapter 21 \r\n21.6 Exercises \r\n\r\nPart 5 Object-Oriented Design\r\n\r\n22 Object-Oriented Design \r\n\r\n22.1 Software Engineering \r\n22.2 The Software Life Cycle \r\n22.2.1 Requirements \r\n22.2.2 Design \r\n22.2.3 Coding \r\n22.2.4 Testing\r\n22.2.5 Maintenance \r\n22.3 Design \r\n22.3.1 The Design Process \r\n22.3.2 Functional Design \r\n22.4 Object-Oriented Design (OOD) \r\n22.4.1 Capturing Our Design: A Design Notation \r\n22.4.2 Object Identification \r\n22.5 Key Points in Chapter 22\r\n22.6 Exercises \r\n22.7 References\r\n\r\n23 Case Study: Implementing the Personal Organizer 1 \r\n\r\n23.1 First Steps in the Design \r\n23.2 File Organization \r\n23.2.1 Index Sequential Access \r\n23.2.2 The Main File \r\n23.2.3 The Rand0mAccessFile Class \r\n23.2.4 The Index \r\n23.2.5 Suitability of the Vector Class for Internal Representation of the Index \r\n23.2.6 Suitability of the Hashtabl e Class for Internal Representation of the Index \r\n23.2.7 Using the Vector Class Indirectly \r\n23.3 The Classes in Detail \r\n23.3.1 Filing System Considerations \r\n23.3.2 Clientship \r\n23.4 Moving toward Implementation \r\n23.4.1 The DirBase Class \r\n23.4.2 The DirEntry Class\r\n23.4.3 The IndexElem Class \r\n23.4.4 The Index Class \r\n23.5 Key Points in Chapter 23 \r\n23.6 Exercise \r\n23.7 Reference\r\n\r\n24 Case Study: Implementing the Personal Organizer 2 \r\n\r\n24.1 Completing the Implementation \r\n24.2 Implementation of DirBase, Index, IndexElem, and DirEntry \r\n24.2.1 D irEntry Class Source and Commentary \r\n24.2.2 IndexElem Class Source and Commentary \r\n24.2.3 Index Class Source and Commentary \r\n24.2.4 DirBase Class Source and Commentary \r\n24.3 Testing What We Have Done So Far \r\n24.3.1 Using a StreamTokenizer \r\n24.3.2 Test-Based Interface: Intermediate Application and Testing \r\n24.3.3 What Are We Testing? \r\n24.4 Graphical User Interface: The Final Prototype Application \r\n24.4.1 Testing the Graphical Interface \r\n24.5 Using Inheritance \r\n24.6 Key Points in Chapter 24 \r\n24.7 Exercises \r\n\r\n25 Criteria for a Good Object-Oriented Design \r\n\r\n25.1 Introduction \r\n25.2 Cohesion \r\n25.3 Coupling \r\n25.3.1 The Law of Demeter \r\n25.4 Clarity \r\n25.5 Extensibility of Our Design \r\n25.5.1 Adding an Email Attribute to a Directory Entry \r\n25.5.2 Adding a Diary Feature to the Personal Organizer \r\n25.6 Key Points in Chapter 25 \r\n25.7 Exercises \r\n25.8 References\r\n\r\nPart 6 Appendixes\r\n\r\nA Getting Started with Java \r\nB Keywords in Java \r\nC ASCII and Unicode Characters \r\nD Program Listings \r\n\r\nD.1 Person. Java \r\nD.2 Chapter20n2. java \r\nD.3 The GUI Source Code for the Java Persona] Organizer \r\nD.3.1 The Gui Class \r\nD.3.2 The DirGui Class \r\nD.3.3 The BrowseRecGui Class \r\nD.3.4 The NewRecGui Class \r\nD.3.5 The AlertDialog Class \r\n\r\nIndex
无封面