Java核心技術卷Ⅰ:基礎知識

Java核心技術卷Ⅰ:基礎知識

《Java核心技術卷Ⅰ基礎知識》是2011年6月電子工業出版社出版的圖書,作者是(美)科內爾(Cornell,G.),譯者是公飛。

基本介紹

  • 書名:Java核心技術卷Ⅰ:基礎知識
  • 作者:(美)科內爾(Cornell,G.)
  • ISBN:9787121133626
  • 類別:公飛
  • 頁數:648頁
  • 定價:99.00元
  • 出版社:電子工業出版社
  • 出版時間:2011年6月
  • 裝幀:16開
內容簡介,評註者序,圖書目 錄,

內容簡介

《Java核心技術》(Core Java)自第1版出版以來,一直備受廣大Java程式設計人員的青睞,暢銷不衰,是Java經典書籍。第8版針對Java SE 6平台進行了全面更新,囊括了Java平台標準版(Java SE/J2SE)的全部基礎知識,提供了大量完整且具有實際意義的套用實例,詳細介紹了Java語言基礎知識、面向對象程式設計、接口與內部類、事件監聽器模型、swing圖形用戶界面程式設計、打包應用程式、異常處理、登錄與調試、泛型程式設計、集合框架、多執行緒等內容。
本評註版力邀國內資深專家執筆,在英文原著基礎上增加了點評和注釋,並對原書內容進行了精簡,刪除了Java圖形視窗編程的相關內容,即原書的第7~10章,同時對章節序號進行了相應的調整,從而使本書更集中於Java核心語言。
本評註版的目的旨在以先行者的學研心得與實踐感悟,對讀者的閱讀和學習加以點撥、指明捷徑。
書中示例程式經過精心設計,不但具有實用價值,而且易於閱讀理解,可以作為初學者自己編寫程式的良好開端,也能夠幫助程式設計師快速地了解Java SE 6的新特性,或迅速從其他語言轉向Java語言。
Java核心技術卷Ⅰ:基礎知識

評註者序

大約在八九年前,我剛好是《Java核心技術》第5版的讀者,彈指之間,Java已經歷很多變化,《Java核心技術》也已經升級到了第8版,並且一度成為暢銷圖書。我還曾不止一次向Java新人推薦此書,卻不曾想現在竟有幸成為本書評註版的評註者。重讀本書倍感親切,不由地感嘆一本好書對於學習的正面影響不可限量。
這裡借本書再寫一下個人對Java學習要點的理解,也算是對本書內容的一個導讀(本評註版的內容對原書進行了精簡,刪除了原書的第7~10章,並對原書的章節序號進行了相應的調整。也即是說,本評註版中的第7~10章是原書的11~14章)。
第1章是對Java的概要介紹,其中並不涉及Java的具體語法,但是包含了一些Java創新的思想和方法。當你成為資深設計人員或者成為軟體開發的技術領導者之後,這些創新的思想和方法也許能給你一些啟示。
第2章介紹Java編程環境,包括使用JDK進行基於命令行的開發,以及集成開發環境Eclipse。這是Java編程的基礎,特別是通過掌握基於命令行的開發可以幫助你深刻理解Java的編寫、編譯、運行機制,這個機制的掌握對於學習Java非常重要。
第3章是Java的基礎編程結構。基礎當然重要,這裡不用再多說了。
第4、5章分別介紹了Java的對象和類,以及Java的繼承。這兩章是Java面向對象編程的核心,也是學習Java的關鍵之一。要想成為Java高手,務必深刻理解這兩章的內容。
第6章介紹Java的接口和內部類。內部類並不太重要,但是在程式語言中引入接口絕對是Java最具革命性的創新。這是Java編程構件化架構體系的重要基礎。讀者對Java的接口一定要好好理解。
第7章介紹Java的異常、日誌、斷言和調試等。一個正規的程式一定有著良好的異常處理機制和完善的日誌系統。
第8章介紹Java的范型。范型是Java後來加入的內容,有些複雜,需要你耐心一點,慢慢理解。
第9章介紹Java的集合。本章主要是理解Java的集合類集成與實現體系,以及各種集合類的實現機理與特點,從而能夠恰當地選擇並使用合適的集合類。
第10章介紹Java的多執行緒。多執行緒是軟體開發的高級話題,也是現代程式設計中非常重要的內容,尤其是對於網路服務端程式的開發具有重要的意義。多執行緒編程通常比較複雜,需要仔細理解,正確理解多執行緒運行的原理、概念,以及Java中多執行緒的實現方式是學習本章的關鍵。
雖稱為評註者,然而本人才疏學淺,不可與脂硯齋、金聖歎等同日而語。僅希望能通過評註這種形式與Java初學者形成一種交流,通過對Java學習要點的一些提示和解釋,以及對原書內容的一些補充,讓Java初學者能夠深入理解Java,並快速掌握Java。但願本書能夠對你學習Java帶來幫助。
另外要說明一下,由於本書篇幅較大,為了節省成本和便於讀者對照原書閱讀,本評註版也標出了原書對應的頁碼,本書的索引所列頁碼(包括正文的頁碼引用)為原英文版頁碼。
公飛
2011年3月

圖書目 錄

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 Inner Classes(新增批註共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, and Debugging
(新增批註共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

相關詞條

熱門詞條

聯絡我們