《Java核心技術卷1:基礎知識(第8版)(英文版)》第1版出版以來,一直備受廣大Java程式設計人員的青睞,暢銷不衰,是Java經典書籍。第8版針對Java SE 6平台進行了全面更新,囊括了Java 2平台、標準版(J2SE)的全部基礎知識,提供了大量完整且具有實際意義的套用實例,詳細介紹了Java語言基礎知識、面向對象程式設計、接口與內部類、事件監聽器模型、Swing圖形用戶界面程式設計、打包應用程式、異常處理、登錄與調試、泛型程式設計、集合框架、多執行緒等內容。《Java核心技術卷1:基礎知識(第8版)(英文版)》示例程式經過精心設計,不但具有實用價值,而且易於閱讀理解,可以作為初學者自己編寫程式的良好開端,也能夠幫助程式設計師快速地了解Java SE 6的新特性,或迅速從其他語言轉向Java語言。
基本介紹
- 書名:Java核心技術卷1:基礎知識
- 出版社:人民郵電出版社
- 頁數:836頁
- 開本:16
- 品牌:人民郵電出版社
- 作者:霍斯特曼 (Cay S.Horstmann) 科奈爾 (Gary Cornell)
- 出版日期:2008年11月1日
- 語種:英語
- ISBN:9787115188335
基本介紹
內容簡介
Garv Cornell擁有20餘年程式設計專業課程教學經驗,撰寫過多本專著,曾獲得Jolt大獎提名。
《Java核心技術卷1:基礎知識(第8版)(英文版)》針對Java SE 6平台進行了全面更新,並通過大量經過測試的示例說明了最重要的語言特性和類庫特性。這些示例程式經過精心設計,不但具有實用價值,而且易閱讀和理解,可以作為讀者自己編寫程式的良好開端。本卷詳細介紹以下內容:
Java語言基礎知識;
Swing圖形用戶界面程式設計;
泛型程式設計;
面向對象程式設計;
打包應用程式;
集合框架;
接口與內部類;
異常處理;
多執行緒。
事件監聽器模型;
登錄與調試。
作者簡介
圖書目錄
Java As a Programming Platform
The Java “White Paper” Buzzwords
Simple
Object Oriented
Network-Savvy
Robust
Secure
Architecture Neutral
Portable
Interpreted
High Performance
Multithreaded
Dynamic
Java Applets and the Internet
A Short History of Java
Common Misconceptions about Java
2 THE JAVA PROGRAMMING ENVIRONMENT
Installing the Java Development Kit
Downloading the JDK
Setting the Execution Path
Installing the Library Source and Documentation
Installing the Core Java Program Examples
Navigating the Java Directories
Choosing a Development Environment
Using the Command-Line Tools
Troubleshooting Hints
Using an Integrated Development Environment
Locating Compilation Errors
Running a Graphical Application
Building and Running Applets
3 FUNDAMENTAL PROGRAMMING STRUCTURES IN JAVA
A Simple Java Program
Comments
Data Types
Integer Types
Floating-Point Types
The char Type
The boolean Type
Variables
Initializing Variables
Constants
Operators
Increment and Decrement Operators
Relational and boolean Operators
Bitwise Operators
Mathematical Functions and Constants
Conversions between Numeric Types
Casts
Parentheses and Operator Hierarchy
Enumerated Types
Strings
Substrings
Concatenation
Strings Are Immutable
Testing Strings for Equality
Code Points and Code Units
The String API
Reading the On-Line API Documentation
Building Strings
Input and Output
Reading Input
Formatting Output
File Input and Output
Control Flow
Block Scope
Conditional Statements
Loops
Determinate Loops
Multiple Selections——The switch Statement
Statements That Break Control Flow
Big Numbers
Arrays
The “for each” Loop
Array Initializers and Anonymous Arrays
Array Copying
Command-Line Parameters
Array Sorting
Multidimensional Arrays
Ragged Arrays
4 OBJECTS AND CLASSES
Introduction to Object-Oriented Programming
Classes
Objects
Identifying Classes
Relationships between Classes
Using Predefined Classes
Objects and Object Variables
The GregorianCalendar Class of the Java Library
Mutator and Accessor Methods
Defining Your Own Classes
An Employee Class
Use of Multiple Source Files
Dissecting the Employee Class
First Steps with Constructors
Implicit and Explicit Parameters
Benefits of Encapsulation
Class-Based Access Privileges
Private Methods
Final Instance Fields
Static Fields and Methods
Static Fields
Static Constants
Static Methods
Factory Methods
The main Method
Method Parameters
Object Construction
Overloading
Default Field Initialization
Default Constructors
Explicit Field Initialization
Parameter Names
Calling Another Constructor
Initialization Blocks
Object Destruction and the finalize Method
Packages
Class Importation
Static Imports
Addition of a Class into a Package
Package Scope
The Class Path
Setting the Class Path
Documentation Comments
Comment Insertion
Class Comments
Method Comments
Field Comments
General Comments
Package and Overview Comments
Comment Extraction
Class Design Hints
5 INHERITANCE
Classes, Superclasses, and Subclasses
Inheritance Hierarchies
Polymorphism
Dynamic Binding
Preventing Inheritance: Final Classes and Methods
Casting
Abstract Classes
Protected Access
Object: The Cosmic Superclass
The equals Method
Equality Testing and Inheritance
The hashCode Method
The toString Method
Generic Array Lists
Accessing Array List Elements
Compatibility between Typed and Raw Array Lists
Object Wrappers and Autoboxing
Methods with a Variable Number of Parameters
Enumeration Classes
Reflection
The Class Class
A Primer on Catching Exceptions
Using Reflection to Analyze the Capabilities of Classes
Using Reflection to Analyze Objects at Runtime
Using Reflection to Write Generic Array Code
Method Pointers!
Design Hints for Inheritance
6 INTERFACES AND INNER CLASSES
Interfaces
Properties of Interfaces
Interfaces and Abstract Classes
Object Cloning
Interfaces and Callbacks
Inner Classes
Use of an Inner Class to Access Object State
Special Syntax Rules for Inner Classes
Are Inner Classes Useful? Actually Necessary? Secure?
Local Inner Classes
Accessing final Variables from Outer Methods
Anonymous Inner Classes
Static Inner Classes
Proxies
Properties of Proxy Classes
7 GRAPHICS PROGRAMMING
Introducing Swing
Creating a Frame
Positioning a Frame
Frame Properties
Determining a Good Frame Size
Displaying Information in a Component
Working with 2D Shapes
Using Color
Using Special Fonts for Text
Displaying Images
8 EVENT HANDLING
Basics of Event Handling
Example: Handling a Button Click
Becoming Comfortable with Inner Classes
Creating Listeners Containing a Single Method Call
Example: Changing the Look and Feel
Adapter Classes
Actions
Mouse Events
The AWT Event Hierarchy
Semantic and Low-Level Events
9 USER INTERFACE COMPONENTS WITH SWING
Swing and the Model-View-Controller Design Pattern
Design Patterns
The Model-View-Controller Pattern
A Model-View-Controller Analysis of Swing Buttons
Introduction to Layout Management
Border Layout
Grid Layout
Text Input
Text Fields
Labels and Labeling Components
Password Fields
Text Areas
Scroll Panes
Choice Components
Checkboxes
Radio Buttons
Borders
Combo Boxes
Sliders
Menus
Menu Building
Icons in Menu Items
Checkbox and Radio Button Menu Items
Pop-Up Menus
Keyboard Mnemonics and Accelerators
Enabling and Disabling Menu Items
Toolbars
Tooltips
Sophisticated Layout Management
The Grid Bag Layout
Group Layout
Using No Layout Manager
Custom Layout Managers
Traversal Order
Dialog Boxes
Option Dialogs
Creating Dialogs
Data Exchange
File Dialogs
Color Choosers
10 DEPLOYING APPLICATIONS AND APPLETS
JAR Files
The Manifest
Executable JAR Files
Resources
Sealing
Java Web Start
The Sandbox
Signed Code
The JNLP API
Applets
A Simple Applet
The Applet HTML Tag and Its Attributes
The object Tag
Use of Parameters to Pass Information to Applets
Accessing Image and Audio Files
The Applet Context
Storage of Application Preferences
Property Maps
The Preferences API
11 EXCEPTIONS, LOGGING, ASSERTIONS, AND DEBUGGING
Dealing with Errors
The Classification of Exceptions
Declaring Checked Exceptions
How to Throw an Exception
Creating Exception Classes
Catching Exceptions
Catching Multiple Exceptions
Rethrowing and Chaining Exceptions
The finally Clause
Analyzing Stack Trace Elements
Tips for Using Exceptions
Using Assertions
Assertion Enabling and Disabling
Using Assertions for Parameter Checking
Using Assertions for Documenting Assumptions
Logging
Basic Logging
Advanced Logging
Changing the Log Manager Configuration
Localization
Handlers
Filters
Formatters
A Logging Recipe
Debugging Tips
Using a Console Window
Tracing AWT Events
Letting the AWT Robot Do the Work
Using a Debugger
12 GENERIC PROGRAMMING
Why Generic Programming?
Who Wants to Be a Generic Programmer?
Definition of a Simple Generic Class
Generic Methods
Bounds for Type Variables
Generic Code and the Virtual Machine
Translating Generic Expressions
Translating Generic Methods
Calling Legacy Code
Restrictions and Limitations
Type Parameters Cannot Be Instantiated with Primitive Types
Runtime Type Inquiry Only Works with Raw Types
You Cannot Throw or Catch Instances of a Generic Class
Arrays of Parameterized Types Are Not Legal
You Cannot Instantiate Type Variables
Type Variables Are Not Valid in Static Contexts of Generic Classes
Beware of Clashes After Erasure
Inheritance Rules for Generic Types
Wildcard Types
Supertype Bounds for Wildcards
Unbounded Wildcards
Wildcard Capture
Reflection and Generics
Using Class Parameters for Type Matching
Generic Type Information in the Virtual Machine
13 COLLECTIONS
Collection Interfaces
Separating Collection Interfaces and Implementation
Collection and Iterator Interfaces in the Java Library
Concrete Collections
Linked Lists
Array Lists
Hash Sets
Tree Sets
Object Comparison
Queues and Deques
Priority Queues
Maps
Specialized Set and Map Classes
The Collections Framework
Views and Wrappers
Bulk Operations
Converting between Collections and Arrays
Algorithms
Sorting and Shuffling
Binary Search
Simple Algorithms
Writing Your Own Algorithms
Legacy Collections
The Hashtable Class
Enumerations
Property Maps
Stacks
Bit Sets
14 MULTITHREADING
What Are Threads?
Using Threads to Give Other Tasks a Chance
Interrupting Threads
Thread States
New Threads
Runnable Threads
Blocked and Waiting Threads
Terminated Threads
Thread Properties
Thread Priorities
Daemon Threads
Handlers for Uncaught Exceptions
Synchronization
An Example of a Race Condition
The Race Condition Explained
Lock Objects
Condition Objects
The synchronized Keyword
Synchronized Blocks
The Monitor Concept
Volatile Fields
Deadlocks
Lock Testing and Timeouts
Read/Write Locks
Why the stop and suspend Methods Are Deprecated
Blocking Queues
Thread-Safe Collections
Efficient Maps, Sets, and Queues
Copy on Write Arrays
Older Thread-Safe Collections
Callables and Futures
Executors
Thread Pools
Scheduled Execution
Controlling Groups of Tasks
Synchronizers
Semaphores
Countdown Latches
Barriers
Exchangers
Synchronous Queues
Example: Pausing and Resuming an Animation
Threads and Swing
Running Time-Consuming Tasks
Using the Swing Worker
The Single-Thread Rule
Appendix
Index
序言
1995年以來,SUN MicroSystems公司已經發布了Java開發工具箱(Java Development Kit)的7個主要版本。在過去的11年中,應用程式接口(API)已經從200個類擴展到3000個類,並覆蓋了用戶界面構建、資料庫管理、國際化、安全性以及XML處理等各個不同的領域。
本書是《Java核心技術》第8版的卷I。自《Java核心技術》出版以來,每個新版本都儘可能快地跟上Java開發工具箱發展的步伐,並重新改寫部分內容,以適應Java的最新特性。在這一版中,已經反映了Java標準版(Java SE 6)的特性。
與前幾版一樣,本版仍然將讀者群定位在那些打算將Java套用到實際工程項目中的程式設計人員。本書假設讀者是一名具有程式設計語言(除Java之外)堅實背景知識的程式設計人員,並且不希望書中充斥著玩具式的示例(諸如烤麵包機、動物園的動物或神經質的跳動文本)。這些內容絕對不會在本書中出現。本書的目標是讓讀者充分地理解書中介紹的Java語言及Java類庫的相關特性,而不會產生任何誤解。
在本書中,我們選用大量的示例代碼演示所討論的每一個語言特性和類庫特性。我們有意使用簡單的示例程式以突出重點,然而,其中的大部分既不是贗品也沒有偷工減料。它們將成為讀者自己編寫代碼的良好開端。