书籍详情
Java核心技术·卷Ⅰ:基础知识(评注版 第8版)
作者:(美)科内尔(Cornell,G.)著
出版社:电子工业出版社
出版时间:2011-06-01
ISBN:9787121133626
定价:¥99.00
购买这本书可以去
内容简介
《Java核心技术·卷Ⅰ:基础知识(第8版)(评注版)》(Core Java)自第1版出版以来,一直备受广大Java程序设计人员的青睐,畅销不衰,是Java经典书籍。第8版针对Java SE 6平台进行了全面更新,囊括了Java平台标准版(Java SE/J2SE)的全部基础知识,提供了大量完整且具有实际意义的应用实例,详细介绍了Java语言基础知识、面向对象程序设计、接口与内部类、事件监听器模型、swing图形用户界面程序设计、打包应用程序、异常处理、登录与调试、泛型程序设计、集合框架、多线程等内容。本评注版力邀国内资深专家执笔,在英文原著基础上增加了点评和注释,并对原书内容进行了精简,删除了Java图形窗口编程的相关内容,即原书的第7-10章,同时对章节序号进行了相应的调整,从而使本书更集中于Java核心语言。本评注版的目的旨在以先行者的学研心得与实践感悟,对读者的阅读和学习加以点拨、指明捷径。《Java核心技术·卷Ⅰ:基础知识(第8版)(评注版)》中示例程序经过精心设计,不但具有实用价值,而且易于阅读理解,可以作为初学者自己编写程序的良好开端,也能够帮助程序员快速地了解Java SE 6的新特性,或迅速从其他语言转向Java语言。
作者简介
Horstmann Cay S.Horstmann ,圣何塞州立大学计算机科学系教授。他曾经是Preview Systems公司的副总裁和首席技术官,曾任许多大型公司、大学和组织的C++、Java与因特网编程顾问。
目录
Preface XVIII
Acknowledgements XXIV
Chapter 1 An Introduction to Java(新增批注共25条) 1
Java As a Programming Platform 2
The Java “White Paper” Buzzwords 3
Simple 3
Object Oriented 4
Network-Savvy 5
Robust 5
Secure 6
Architecture Neutral 7
Portable 8
Interpreted 9
High Performance 9
Multithreaded 10
Dynamic 10
Java Applets and the Internet 11
A Short History of Java 12
Common Misconceptions about Java 15
Chapter 2 The Java Programming Environment
(新增批注共20条) 21
Installing the Java Development Kit 22
Downloading the JDK 22
Setting the Execution Path 26
Installing the Library Source and Documentation 28
Installing the Core Java Program Examples 28
Navigating the Java Directories 29
Choosing a Development Environment 32
Using the Command-Line Tools 33
Troubleshooting Hints 43
Using an Integrated Development Environment 45
Locating Compilation Errors 49
Running a Graphical Application 55
Building and Running Applets 58
Chapter 3 Fundamental Programming Structures in Java
(新增批注共44条) 63
A Simple Java Program 64
Comments 68
Data Types 70
Integer Types 70
Floating-Point Types 71
The char Type 72
The boolean Type 74
Variables 74
Initializing Variables 76
Constants 76
Operators 77
Increment and Decrement Operators 78
Relational and boolean Operators 79
Bitwise Operators 81
Mathematical Functions and Constants 81
Conversions between Numeric Types 83
Casts 84
Parentheses and Operator Hierarchy 84
Enumerated Types 85
Strings 86
Substrings 86
Concatenation 86
Strings Are Immutable 87
Testing Strings for Equality 88
Code Points and Code Units 89
The String API 90
Reading the On-Line API Documentation 92
Building Strings 95
Input and Output 96
Reading Input 96
Formatting Output 98
File Input and Output 103
Control Flow 105
Block Scope 105
Conditional Statements 106
Loops 109
Determinate Loops 113
Multiple Selections—The switch Statement 117
Statements That Break Control Flow 119
Big Numbers 122
Arrays 124
The “for each” Loop 125
Array Initializers and Anonymous Arrays 126
Array Copying 126
Command-Line Parameters 128
Array Sorting 129
Multidimensional Arrays 132
Ragged Arrays 135
Chapter 4 Objects and Classes(新增批注共55条) 139
Introduction to Object-Oriented Programming 140
Classes 142
Objects 143
Identifying Classes 143
Relationships between Classes 144
Using Predefined Classes 146
Objects and Object Variables 146
The GregorianCalendar Class of the Java Library 150
Mutator and Accessor Methods 152
Defining Your Own Classes 158
An Employee Class 158
Use of Multiple Source Files 162
Dissecting the Employee Class 163
First Steps with Constructors 164
Implicit and Explicit Parameters 166
Benefits of Encapsulation 167
Class-Based Access Privileges 170
Private Methods 171
Final Instance Fields 171
Static Fields and Methods 172
Static Fields 172
Static Constants 173
Static Methods 174
Factory Methods 175
The main Method 175
Method Parameters 178
Object Construction 185
Overloading 185
Default Field Initialization 185
Default Constructors 186
Explicit Field Initialization 187
Parameter Names 188
Calling Another Constructor 188
Initialization Blocks 189
Object Destruction and the finalize Method 193
Packages 194
Class Importation 195
Static Imports 196
Addition of a Class into a Package 197
Package Scope 200
The Class Path 201
Setting the Class Path 203
Documentation Comments 204
Comment Insertion 204
Class Comments 205
Method Comments 205
Field Comments 206
General Comments 206
Package and Overview Comments 207
Comment Extraction 207
Class Design Hints 208
Chapter 5 Inheritance(新增批注共42条) 213
Classes, Superclasses, and Subclasses 214
Inheritance Hierarchies 222
Polymorphism 222
Dynamic Binding 224
Preventing Inheritance: Final Classes and Methods 226
Casting 227
Abstract Classes 229
Protected Access 234
Object: The Cosmic Superclass 235
The equals Method 236
Equality Testing and Inheritance 238
The hashCode Method 240
The toString Method 243
Generic Array Lists 248
Accessing Array List Elements 250
Compatibility between Typed and Raw Array Lists 254
Object Wrappers and Autoboxing 256
Methods with a Variable Number of Parameters 259
Enumeration Classes 260
Reflection 263
The Class Class 263
A Primer on Catching Exceptions 266
Using Reflection to Analyze the Capabilities of Classes 268
Using Reflection to Analyze Objects at Runtime 273
Using Reflection to Write Generic Array Code 277
Method Pointers! 281
Design Hints for Inheritance 284
Chapter 6 Interfaces and InnerClasses(新增批注共24条) 289
Interfaces 290
Properties of Interfaces 296
Interfaces and Abstract Classes 297
Object Cloning 298
Interfaces and Callbacks 305
Inner Classes 307
Use of an Inner Class to Access Object State 309
Special Syntax Rules for Inner Classes 312
Are Inner Classes Useful? Actually Necessary? Secure? 313
Local Inner Classes 316
Accessing final Variables from Outer Methods 316
Anonymous Inner Classes 319
Static Inner Classes 322
Proxies 325
Properties of Proxy Classes 333
Chapter 7 Exceptions, Logging, Assertions, andDebugging
(新增批注共38条) 335
Dealing with Errors 336
The Classification of Exceptions 338
Declaring Checked Exceptions 340
How to Throw an Exception 342
Creating Exception Classes 343
Catching Exceptions 344
Catching Multiple Exceptions 346
Rethrowing and Chaining Exceptions 348
The finally Clause 349
Analyzing Stack Trace Elements 352
Tips for Using Exceptions 357
Using Assertions 361
Assertion Enabling and Disabling 361
Using Assertions for Parameter Checking 362
Using Assertions for Documenting Assumptions 363
Logging 364
Basic Logging 364
Advanced Logging 365
Changing the Log Manager Configuration 367
Localization 368
Handlers 369
Filters 373
Formatters 373
A Logging Recipe 373
Debugging Tips 381
Using a Console Window 387
Tracing AWT Events 389
Letting the AWT Robot Do the Work 393
Using a Debugger 396
Chapter 8 Generic Programming(新增批注共22条) 401
Why Generic Programming? 402
Who Wants to Be a Generic Programmer? 403
Definition of a Simple Generic Class 404
Generic Methods 406
Bounds for Type Variables 407
Generic Code and the Virtual Machine 409
Translating Generic Expressions 411
Translating Generic Methods 411
Calling Legacy Code 413
Restrictions and Limitations 414
Type Parameters Cannot Be Instantiated with Primitive Types 414
Runtime Type Inquiry Only Works with Raw Types 415
You Cannot Throw or Catch Instances of a Generic Class 415
Arrays of Parameterized Types Are Not Legal 416
You Cannot Instantiate Type Variables 416
Type Variables Are Not Valid in Static Contexts of Generic Classes 418
Beware of Clashes After Erasure 418
Inheritance Rules for Generic Types 419
Wildcard Types 421
Supertype Bounds for Wildcards 423
Unbounded Wildcards 424
Wildcard Capture 425
Reflection and Generics 430
Using Class<T> Parameters for Type Matching 431
Generic Type Information in the Virtual Machine 431
Chapter 9 Collections(新增批注共55条) 437
Collection Interfaces 438
Separating Collection Interfaces and Implementation 439
Collection and Iterator Interfaces in the Java Library 441
Concrete Collections 447
Linked Lists 448
Array Lists 459
Hash Sets 459
Tree Sets 463
Object Comparison 464
Queues and Deques 469
Priority Queues 471
Maps 472
Specialized Set and Map Classes 476
The Collections Framework 481
Views and Wrappers 487
Bulk Operations 493
Converting between Collections and Arrays 494
Algorithms 494
Sorting and Shuffling 496
Binary Search 498
Simple Algorithms 499
Writing Your Own Algorithms 500
Legacy Collections 502
The Hashtable Class 502
Enumerations 502
Property Maps 503
Stacks 504
Bit Sets 504
Chapter 10 Multithreading(新增批注共24条) 509
What Are Threads? 511
Using Threads to Give Other Tasks a Chance 517
Interrupting Threads 524
Thread States 528
New Threads 529
Runnable Threads 529
Blocked and Waiting Threads 530
Terminated Threads 530
Thread Properties 531
Thread Priorities 531
Daemon Threads 533
Handlers for Uncaught Exceptions 534
Synchronization 535
An Example of a Race Condition 536
The Race Condition Explained 540
Lock Objects 541
Condition Objects 544
The synchronized Keyword 549
Synchronized Blocks 553
The Monitor Concept 554
Volatile Fields 555
Deadlocks 556
Lock Testing and Timeouts 559
Read/Write Locks 560
Why the stop and suspend Methods Are Deprecated 561
Blocking Queues 563
Thread-Safe Collections 570
Efficient Maps, Sets, and Queues 570
Copy on Write Arrays 572
Older Thread-Safe Collections 572
Callables and Futures 573
Executors 577
Thread Pools 578
Scheduled Execution 582
Controlling Groups of Tasks 583
Synchronizers 584
Semaphores 585
Countdown Latches 585
Barriers 585
Exchangers 586
Synchronous Queues 586
Example: Pausing and Resuming an Animation 586
Threads and Swing 592
Running Time-Consuming Tasks 594
Using the Swing Worker 598
The Single-Thread Rule 604
Index 607
Acknowledgements XXIV
Chapter 1 An Introduction to Java(新增批注共25条) 1
Java As a Programming Platform 2
The Java “White Paper” Buzzwords 3
Simple 3
Object Oriented 4
Network-Savvy 5
Robust 5
Secure 6
Architecture Neutral 7
Portable 8
Interpreted 9
High Performance 9
Multithreaded 10
Dynamic 10
Java Applets and the Internet 11
A Short History of Java 12
Common Misconceptions about Java 15
Chapter 2 The Java Programming Environment
(新增批注共20条) 21
Installing the Java Development Kit 22
Downloading the JDK 22
Setting the Execution Path 26
Installing the Library Source and Documentation 28
Installing the Core Java Program Examples 28
Navigating the Java Directories 29
Choosing a Development Environment 32
Using the Command-Line Tools 33
Troubleshooting Hints 43
Using an Integrated Development Environment 45
Locating Compilation Errors 49
Running a Graphical Application 55
Building and Running Applets 58
Chapter 3 Fundamental Programming Structures in Java
(新增批注共44条) 63
A Simple Java Program 64
Comments 68
Data Types 70
Integer Types 70
Floating-Point Types 71
The char Type 72
The boolean Type 74
Variables 74
Initializing Variables 76
Constants 76
Operators 77
Increment and Decrement Operators 78
Relational and boolean Operators 79
Bitwise Operators 81
Mathematical Functions and Constants 81
Conversions between Numeric Types 83
Casts 84
Parentheses and Operator Hierarchy 84
Enumerated Types 85
Strings 86
Substrings 86
Concatenation 86
Strings Are Immutable 87
Testing Strings for Equality 88
Code Points and Code Units 89
The String API 90
Reading the On-Line API Documentation 92
Building Strings 95
Input and Output 96
Reading Input 96
Formatting Output 98
File Input and Output 103
Control Flow 105
Block Scope 105
Conditional Statements 106
Loops 109
Determinate Loops 113
Multiple Selections—The switch Statement 117
Statements That Break Control Flow 119
Big Numbers 122
Arrays 124
The “for each” Loop 125
Array Initializers and Anonymous Arrays 126
Array Copying 126
Command-Line Parameters 128
Array Sorting 129
Multidimensional Arrays 132
Ragged Arrays 135
Chapter 4 Objects and Classes(新增批注共55条) 139
Introduction to Object-Oriented Programming 140
Classes 142
Objects 143
Identifying Classes 143
Relationships between Classes 144
Using Predefined Classes 146
Objects and Object Variables 146
The GregorianCalendar Class of the Java Library 150
Mutator and Accessor Methods 152
Defining Your Own Classes 158
An Employee Class 158
Use of Multiple Source Files 162
Dissecting the Employee Class 163
First Steps with Constructors 164
Implicit and Explicit Parameters 166
Benefits of Encapsulation 167
Class-Based Access Privileges 170
Private Methods 171
Final Instance Fields 171
Static Fields and Methods 172
Static Fields 172
Static Constants 173
Static Methods 174
Factory Methods 175
The main Method 175
Method Parameters 178
Object Construction 185
Overloading 185
Default Field Initialization 185
Default Constructors 186
Explicit Field Initialization 187
Parameter Names 188
Calling Another Constructor 188
Initialization Blocks 189
Object Destruction and the finalize Method 193
Packages 194
Class Importation 195
Static Imports 196
Addition of a Class into a Package 197
Package Scope 200
The Class Path 201
Setting the Class Path 203
Documentation Comments 204
Comment Insertion 204
Class Comments 205
Method Comments 205
Field Comments 206
General Comments 206
Package and Overview Comments 207
Comment Extraction 207
Class Design Hints 208
Chapter 5 Inheritance(新增批注共42条) 213
Classes, Superclasses, and Subclasses 214
Inheritance Hierarchies 222
Polymorphism 222
Dynamic Binding 224
Preventing Inheritance: Final Classes and Methods 226
Casting 227
Abstract Classes 229
Protected Access 234
Object: The Cosmic Superclass 235
The equals Method 236
Equality Testing and Inheritance 238
The hashCode Method 240
The toString Method 243
Generic Array Lists 248
Accessing Array List Elements 250
Compatibility between Typed and Raw Array Lists 254
Object Wrappers and Autoboxing 256
Methods with a Variable Number of Parameters 259
Enumeration Classes 260
Reflection 263
The Class Class 263
A Primer on Catching Exceptions 266
Using Reflection to Analyze the Capabilities of Classes 268
Using Reflection to Analyze Objects at Runtime 273
Using Reflection to Write Generic Array Code 277
Method Pointers! 281
Design Hints for Inheritance 284
Chapter 6 Interfaces and InnerClasses(新增批注共24条) 289
Interfaces 290
Properties of Interfaces 296
Interfaces and Abstract Classes 297
Object Cloning 298
Interfaces and Callbacks 305
Inner Classes 307
Use of an Inner Class to Access Object State 309
Special Syntax Rules for Inner Classes 312
Are Inner Classes Useful? Actually Necessary? Secure? 313
Local Inner Classes 316
Accessing final Variables from Outer Methods 316
Anonymous Inner Classes 319
Static Inner Classes 322
Proxies 325
Properties of Proxy Classes 333
Chapter 7 Exceptions, Logging, Assertions, andDebugging
(新增批注共38条) 335
Dealing with Errors 336
The Classification of Exceptions 338
Declaring Checked Exceptions 340
How to Throw an Exception 342
Creating Exception Classes 343
Catching Exceptions 344
Catching Multiple Exceptions 346
Rethrowing and Chaining Exceptions 348
The finally Clause 349
Analyzing Stack Trace Elements 352
Tips for Using Exceptions 357
Using Assertions 361
Assertion Enabling and Disabling 361
Using Assertions for Parameter Checking 362
Using Assertions for Documenting Assumptions 363
Logging 364
Basic Logging 364
Advanced Logging 365
Changing the Log Manager Configuration 367
Localization 368
Handlers 369
Filters 373
Formatters 373
A Logging Recipe 373
Debugging Tips 381
Using a Console Window 387
Tracing AWT Events 389
Letting the AWT Robot Do the Work 393
Using a Debugger 396
Chapter 8 Generic Programming(新增批注共22条) 401
Why Generic Programming? 402
Who Wants to Be a Generic Programmer? 403
Definition of a Simple Generic Class 404
Generic Methods 406
Bounds for Type Variables 407
Generic Code and the Virtual Machine 409
Translating Generic Expressions 411
Translating Generic Methods 411
Calling Legacy Code 413
Restrictions and Limitations 414
Type Parameters Cannot Be Instantiated with Primitive Types 414
Runtime Type Inquiry Only Works with Raw Types 415
You Cannot Throw or Catch Instances of a Generic Class 415
Arrays of Parameterized Types Are Not Legal 416
You Cannot Instantiate Type Variables 416
Type Variables Are Not Valid in Static Contexts of Generic Classes 418
Beware of Clashes After Erasure 418
Inheritance Rules for Generic Types 419
Wildcard Types 421
Supertype Bounds for Wildcards 423
Unbounded Wildcards 424
Wildcard Capture 425
Reflection and Generics 430
Using Class<T> Parameters for Type Matching 431
Generic Type Information in the Virtual Machine 431
Chapter 9 Collections(新增批注共55条) 437
Collection Interfaces 438
Separating Collection Interfaces and Implementation 439
Collection and Iterator Interfaces in the Java Library 441
Concrete Collections 447
Linked Lists 448
Array Lists 459
Hash Sets 459
Tree Sets 463
Object Comparison 464
Queues and Deques 469
Priority Queues 471
Maps 472
Specialized Set and Map Classes 476
The Collections Framework 481
Views and Wrappers 487
Bulk Operations 493
Converting between Collections and Arrays 494
Algorithms 494
Sorting and Shuffling 496
Binary Search 498
Simple Algorithms 499
Writing Your Own Algorithms 500
Legacy Collections 502
The Hashtable Class 502
Enumerations 502
Property Maps 503
Stacks 504
Bit Sets 504
Chapter 10 Multithreading(新增批注共24条) 509
What Are Threads? 511
Using Threads to Give Other Tasks a Chance 517
Interrupting Threads 524
Thread States 528
New Threads 529
Runnable Threads 529
Blocked and Waiting Threads 530
Terminated Threads 530
Thread Properties 531
Thread Priorities 531
Daemon Threads 533
Handlers for Uncaught Exceptions 534
Synchronization 535
An Example of a Race Condition 536
The Race Condition Explained 540
Lock Objects 541
Condition Objects 544
The synchronized Keyword 549
Synchronized Blocks 553
The Monitor Concept 554
Volatile Fields 555
Deadlocks 556
Lock Testing and Timeouts 559
Read/Write Locks 560
Why the stop and suspend Methods Are Deprecated 561
Blocking Queues 563
Thread-Safe Collections 570
Efficient Maps, Sets, and Queues 570
Copy on Write Arrays 572
Older Thread-Safe Collections 572
Callables and Futures 573
Executors 577
Thread Pools 578
Scheduled Execution 582
Controlling Groups of Tasks 583
Synchronizers 584
Semaphores 585
Countdown Latches 585
Barriers 585
Exchangers 586
Synchronous Queues 586
Example: Pausing and Resuming an Animation 586
Threads and Swing 592
Running Time-Consuming Tasks 594
Using the Swing Worker 598
The Single-Thread Rule 604
Index 607
猜您喜欢