|
读过这本书吗?
最近在读
读过
想读
还不熟悉
|
图书城书列:
加入到博客或社交网站:
|
|
我来评论这本书:
内容提要:
本书主要讲授Java程序设计语言,系统地介绍Java的主要包(即java.lang.*、java.util和java.io)中的大多数类,并以内容丰富的示例对这些类如何工作进行了深入剖析。作者对这部经典著作进行更新,使其反映了Java 2标准版5.0(J2SE 5.0)中主要的增强。本版中增加了几章新内容,专门讨论泛型、枚举以及注解(这些是5.0版引入的主要的新特性),并且加了几小节论述断言和正则表达式。本书经过更新后还结合了当今构建健壮、高效和可维护的Java软件的最佳实践。
本书对所有程序员(包括那些经验丰富的程序员在内)都是不可或缺的参考书。 编辑推荐:
本书主要讲授Java程序设计语言,系统地介绍Java的主要包(即java.lang.*、java.util和java.io)中的大多数类,并以内容丰富的示例对这些类如何工作进行了深入剖析。作者对这部经典著作进行更新,使其反映了Java 2标准版5.0(J2SE 5.0)中主要的增强。本版中增加了几章新内容,专门讨论泛型、枚举以及注解(这些是5.0版引入的主要的新特性),并且加了几小节论述断言和正则表达式。本书经过更新后还结合了当今构建健壮、高效和可维护的Java软件的最佳实践。
本书对所有程序员(包括那些经验丰富的程序员在内)都是不可或缺的参考书。 目录:
Contents
1 A Quick Tour 1 1.1 Getting Started 1 1.2 Variables 3 1.3 Comments in Code 6 1.4 Named Constants 7 1.5 Unicode Characters 8 1.6 Flow of Control 9 1.7 Classes and Objects 12 1.7.1 Creating Objects 13 1.7.2 Static or Class Fields 14 1.7.3 The Garbage Collector 15 1.8 Methods and Parameters 15 1.8.1 Invoking a Method 15 1.8.2 The this Reference 17 1.8.3 Static or Class Methods 17 1.9 Arrays 18 1.10 String Objects 21 1.10.1 String Conversion and Formatting 23 1.11 Extending a Class 24 1.11.1 Invoking Methods of the Superclass 25 1.11.2 The 0bject Class 26 1.11.3 Type Casting 27 1.12 Interfaces 27 1.13 Generic Types 29 1.14 Exceptions 32 1.15 Annotations 35 1.16 Packages 36 1.17 The Java Platform 38 1.18 Other Topics Briefly Noted 39 2 Classes and Objects 41 2.1 A Simple Class 42 2.1.1 Class Members 42 2.1.2 Class Modifiers 43 2.2 Fields 44 2.2.1 Field Initialization 44 2.2.2 Static Fields 45 2.2.3 final Fields 46 2.3 Access Control 47 2.4 Creating Objects 49 2.5 Construction and Initialization 50 2.5.1 Constructors 50 2.5.2 Initialization Blocks 54 2.5.3 Static Initialization 55 2.6 Methods 56 2.6.1 Static Methods 58 2.6.2 Method Invocations 58 2.6.3 Methods with Variable Numbers of Arguments 60 2.6.4 Method Execution and Return 62 2.6.5 Parameter Values 63 2.6.6 Using Methods to Control Access 65 2.7 this 68 2.8 Overloading Methods 69 2.9 Importing Static Member Names 71 2.10 The main Method 73 2.11 Native Methods 74 3 Extending Classes 75 3.1 An Extended, Class 76 3.2 Constructors in Extended Classes 80 3.2.1 Constructor Order Dependencies 81 3.3 Inheriting and Redefining Members 84 3.3.1 Overriding 84 3.3.2 Hiding Fields 86 3.3.3 Accessing Inherited Members 86 3.3.4 Accessibility and Overriding 88 3.3.5 Hiding Static Members 89 3.3.6 The super Keyword 89 3.4 Type Compatibility and Conversion 90 3.4.1 Compatibility 90 3.4.2 Explicit Type Casting 91 3.4.3 Testing for Type 92 3.5 What protected Really Means 93 3.6 Marking Methods and Classes final 96 3.7 Abstract Classes and Methods 97 3.8 The Object Class 99 3.9 Cloning Objects 101 3.9.1 Strategies for Cloning 101 3.9.2 Correct Cloning 101 3.9.3 Shallow Versus Deep Cloning 106 3.10 Extending Classes: How and When 107 3.11 Designing a Class to Be Extended 108 3.11.1 Designing a Class to Be Extended 108 3.12 Single Inheritance versus Multiple Inheritance 114 4 Interfaces 117 4.1 A Simple Interface Example 118 4.2 Interface Declarations 120 4.2.1 Interface Constants 121 4.2.2 Interface Methods 122 4.2.3 Interface Modifiers 122 4.3 Extending Interfaces 122 4.3.1 Inheriting and Hiding Constants 123 4.3.2 Inheriting, Overriding, and Overloading Methods 125 4.4 Working with Interfaces 126 4.4.1 Implementing Interfaces 127 4.4.2 Using an Implementation 129 4.5 Marker Interfaces 130 4.6 When to Use Interfaces 131 5 Nested Classes and Interfaces 133 5.1 Static Nested Types 133 5.1.1 Static Nested Types 134 5.1.2 Nested Interfaces 135 5.2 Inner Classes 136 5.2.1 Accessing Enclosing Objects 138 5.2.2 Extending Inner Classes 139 5.2.3 Inheritance, Scoping, and Hiding 140 5.3 Local Inner Classes 142 5.3.1 Inner Classes in Static Contexts 144 5.4 Anonymous Inner Classes 144 5.5 Inheriting Nested Types 146 5.6 Nesting in Interfaces 148 5.6.1 Modifiable Variables in Interfaces 149 5.7 Implementation of Nested Types 149 6 Enumeration Types 151 6.1 A Simple Enum Example 151 6.2 Enum Declarations 152 6.2.1 Enum Modifiers 154 6.3 Enum Constant Declarations 154 6.3.1 Construction 155 6.3.2 Constant Specific Behavior 156 6.4 java.lang.Enum 159 6.5 To Enum or Not 160 7 Tokens, Values, and Variables 161 7.1 Lexical Elements 161 7.1.1 Character Set 161 7.1.2 Comments 163 7.1.3 Tokens 164 7 1 4 Identifiers164 7.1.5 Keywords 165 7.2 Types and Literals 166 7.1.1 Reference Literals 167 7.2.2 Boolean Literals 167 7 2 3 Character Literals 167 7 2 4 Integer Literals 167 7 2 5 Floating-Point Literals 168 7.2.6 String Literals 168 7.2.7 Class Literals 169 7 3 Variables 169 7.3.1 Field and Local Variable Declarations 170 7.3.2 Parameter Variables 171 7.3.3 final Variables 171 7.4 Array Variables 173 7.4.1 Array Modifiers 174 7.4.2 Arrays of Arrays 174 7 4 3 Array Initialization 175 7.4.4 Arrays and Types 177 7.5 The Meanings of Names 178 8 Primitives as Types 183 8.1 Common Fields and Methods 184 8.1.1 Construction 185 8.1.2 Constants 185 8.1.3 Common Methods 186 8.2 Void 187 8.3 Boolean 187 8.4 Number 188 8.4.1 The Integer Wrappers 188 8.4.2 The Floating-Point Wrapper Classes 191 8.5 Character 192 8.5.1 Working with UTF-16 196 8.6 Boxing Conversions 199 9 Operators and Expressions 201 9.1 Arithmetic Operations 201 9.1.1 Integer Arithmetic 202 9 1 2 Floating-Point Arithmetic 202 9.1.3 Strict and Non-Strict Floating-Point Arithmetic 203 9.2 General Operators 204 9.2.1 Increment and Decrement Operators 205 9.2.2 Relational and Equality Operators 206 9.2.3 Logical Operators 207 9.2.4 instanceof 208 9.2.5 Bit Manipulation Operators 208 9 2 6 The Conditional Operator?: 210 9.2.7 Assignment Operators 212 9.2.8 String Concatenation Operator 214 9.2.9 new 214 9.3 Expressions 214 9.3.1 Order of Evaluation 214 9.3.2 Expression Type 215 9.4 Type Conversions 216 9.4.1 Implicit Type Conversions 216 9.4.2 Explicit-Type Casts 217 9.4.3 String Conversions 220 9.5 Operator Precedence and Associativity 221 9.6 Member Access 223 9.6.1 Finding the Right Method 224 10 Control Flow 229 10.1 Statements and Blocks 229 10.2 if-else 230 10.3 switch 232 10.4 while and do-while 235 10.5 for 236 10.5.1 Basic for Statement 236 10.5.2 Enhanced for Statement 239 10.6 Labels 241 10.7 break 241 10.8 continue 244 10.9 return 245 10.10 What, No goto? 246 11 Generic Types 247 11.1 Generic Type Declarations 250 11.1.1 Bounded Type Parameters 252 11.1.2 Nested Generic Types 253 11 2 Working with Generic Types 256 11.2.1 Subtyping and Wildcards 256 11.3 Generic Methods and Constructors 260 11.3.1 Generic Invocations and Type Inference 262 11.4 Wildcard Capture 264 11.5 Under the Hood: Erasure and Raw Types 267 11.5.1 Erasure at Runtime 267 11.5.2 Overloading and Overriding 271 11.6 Finding the Right Method-Revisited 272 11.7 Class Extension and Generic Types 276 12 Exceptions and Assertions 279 12.1 Creating Exception Types 280 12.2 throw 282 12.2.1 Transfer of Control 283 12.2.2 Asynchronous Exceptions 283 12.3 The throws Clause 283 12.3.1 throws Clauses and Method Overriding 285 12.3.2 throws Clauses and Native Methods 286 12.4 try, catch, and finally 286 12.4.1 finally 288 12.5 Exception Chaining 291 12.6 Stack Traces 294 12.7 When to Use Exceptions 294 12.8 Assertions 296 12.8.1 The assert Statement 297 12.9 When to Use Assertions 297 12.9.1 State Assertions 297 12.9.2 Control Flow Assertions 299 12.10 Turning Assertions On and Off 300 12.10.1 Why Turn Assertions On and Off? 300 12.10.2 Controlling Assertions on the Command Line 300 12.10.3 Complete Removal 302 12.10.4 Making Assertions Required 302 13 Strings and Regular Expressions 305 13.1 Character Sequences 305 13.2 |