Chapter 1: An Introduction to Java 1 1.1 Java As a Programming Platform . 1 1.2 The Java “White Paper” Buzzwords 2 1.2.1 Simple 3 1.2.2 Object-Oriented 4 1.2.3 Network-Savvy 4 1.2.4 Robust 5 1.2.5 Secure 5 1.2.6 Architecture-Neutral . 6 1.2.7 Portable . 7 1.2.8 Interpreted 7 1.2.9 High-Performance . 8 1.2.10 Multithreaded 8 1.2.11 Dynamic 8 1.3 Java Applets and the Internet 9 1.4 A Short History of Java . 10 1.5 Common Misconceptions about Java . 13
Chapter 2: The Java Programming Environment 17 2.1 Installing the Java Development Kit 18 2.1.1 Downloading the JDK . 18 2.1.2 Setting the Executable Path 20 2.1.3 Installing the Library Source and Documentation . 22 2.1.4 Installing the Core Java Program Examples 23 2.1.5 Navigating the Java Directories . 24 2.2 Choosing a Development Environment 24 2.3 Using the Command-Line Tools . 25 2.3.1 Troubleshooting Hints 27 2.4 Using an Integrated Development Environment . 28 2.4.1 Locating Compilation Errors . 32 2.5 Running a Graphical Application . 33 2.6 Building and Running Applets . 36
Chapter 3: Fundamental Programming Structures in Java 41 3.1 A Simple Java Program 42 3.2 Comments 45 3.3 Data Types 46 3.3.1 Integer Types 47 3.3.2 Floating-Point Types . 48 3.3.3 The char Type . 49 3.3.4 The boolean Type . 51 3.4 Variables . 52 3.4.1 Initializing Variables . 53 3.4.2 Constants 54 3.5 Operators 55 3.5.1 Increment and Decrement Operators . 56 3.5.2 Relational and boolean Operators . 57 3.5.3 Bitwise Operators 58 3.5.4 Mathematical Functions and Constants . 59 3.5.5 Conversions between Numeric Types 60 3.5.6 Casts . 61 3.5.7 Parentheses and Operator Hierarchy . 62 3.5.8 Enumerated Types . 63 3.6 Strings . 64 3.6.1 Substrings . 64 3.6.2 Concatenation 64 3.6.3 Strings Are Immutable 65 3.6.4 Testing Strings for Equality 67 3.6.5 Empty and Null Strings 68 3.6.5 Code Points and Code Units 68 3.6.6 The String API 69 3.6.7 Readingthe Online API Documentation . 72 3.6.8 Building Strings . 74 3.7 Input and Output 76 3.7.1 Reading Input . 76 3.7.2 Formatting Output 79 3.7.3 File Input and Output . 84 3.8 Control Flow 86 3.8.1 Block Scope . 86 3.8.2 Conditional Statements . 87 3.8.3 Loops . 91 3.8.4 Determinate Loops 95 3.8.5 Multiple Selections—The switch Statement 99 3.8.6 Statements That Break Control Flow 102 3.9 Big Numbers 105 3.10 Arrays 107 3.10.1 The “for each” Loop 109 3.10.2 Array Initializers and Anonymous Arrays 110 3.10.3 Array Copying . 111 3.10.4 Command-Line Parameters . 112 3.10.5 Array Sorting 113 3.10.6 Multidimensional Arrays . 116 3.10.7 Ragged Arrays . 120
Chapter 4: Objects and Classes 125 4.1 Introduction to Object-Oriented Programming 126 4.1.1 Classes . 127 4.1.2 Objects . 128 4.1.3 Identifying Classes 129 4.1.4 Relationships between Classes 129 4.2 Using Predefined Classes . 132 4.2.1 Objects and Object Variables . 132 4.2.2 The GregorianCalendar Class of the Java Library . 136 4.2.3 Mutator and Accessor Methods 138 4.3 Defining Your Own Classes . 145 4.3.1 An Employee Class 145 4.3.2 Use of Multiple Source Files 148 4.3.3 Dissecting the Employee Class . 149 4.3.4 First Steps with Constructors . 150 4.3.5 Implicit and Explicit Parameters . 152 4.3.6 Benefits of Encapsulation . 153 4.3.7 Class-Based Access Privileges . 156 4.3.8 Private Methods . 156 4.3.9 Final Instance Fields 157 4.4 Static Fields and Methods 157 4.4.1 Static Fields . 157 4.4.2 Static Constants 158 4.4.3 Static Methods 159 4.4.4 Factory Methods 161 4.4.5 The main Method 161 4.5 Method Parameters . 164 4.6 Object Construction 171 4.6.1 Overloading 171 4.6.2 Default Field Initialization . 172 4.6.3 The Constructor with No Arguments 173 4.6.4 Explicit Field Initialization . 174 4.6.5 Parameter Names 175 4.6.6 Calling Another Constructor . 176 4.6.7 Initialization Blocks . 176 4.6.8 Object Destruction and the finalizeMe
以下为对购买帮助不大的评价