Chapter 1 Classes and Objects
1.1 Java Program Structure
1.2 A First Program
1.3 Defining Methods
1.4 Data Types and Variable Declarations
1.5 Data Abstraction and Encapsulation
1.6 Classes and Objects
1.7 String Basics
1.8 Arrays
1.9 Method Invocation and Argument Passing
1.10 Standard I/O
1.11 Command-line Arguments and main
1.12 Problem Solving with Objects
1.13 Solution via Objects
1.14 Object-oriented Thinking
1.15 Code Organization
1.16 Programming Tips
1.17 Summary
Exercises
Chapter 2 Java Features and Constructs
2.1 ASCII Character I/O
2.2 File I/O
2.3 Basic Error and Exception Handling
2.4 A Class of Fractions
2.5 Identifier Scoping
2.6 Instance and Classwide Members
2.7 Symbolic Constants
2.8 Using Arrays: Quicksort
2.9 String and StringBuffer
2.10 Two-Dimensional Arrays
2.11 A Matrix Class
2.12 Type Conversions
2.13 Implicit Type Conversion
2.14 Explicit Type Casts
2.15 Programming Tips
2.16 Summary
Exercises
Chapter 3 Object-Based Programming
3.1 A Term Life Insurance Account
3.2 A Term Life Premium Calculator
3.3 Java Wrapper Classes
3.4 Operations on Characters
3.5 A URL Decoder
3.6 A Circular Buffer
3.7 Pocket Calculator Simulation
3.8 Linked List
3.9 Overloading Methods
3.10 Storage Allocation and Management
3.11 Summary
Exercises
Chapter 4 Inheritance and Class Extension
4.1 Advantages of Inheritance
4.2 Class Extension Basics
4.3 Class Scope Nesting
4.4 Extended Object Composition
4.5 Free Checking Account
4.6 Access Control under Class Extension
4.7 Class Extension Principles
4.8 Subclass Constructors
4.9 Subclass Finalize
4.10 Type Relations under Inheritance
4.11 Field Access under Subclassing
4.12 Hiding of Fields and Static Methods
4.13 Method Access under Subclassing
4.14 Method Overriding
4.15 Dynamic Invocation of Overriding Methods
4.16 Example: Numeric Wrapper Classes
4.17 Method Overloading in Subclasses
4.18 Calculator with SQRT
4.19 The Object Class and Generic Codes
4.20 Managing Text Lines
4.21 Writing Generic Programs
4.22 Generic List
4.23 Generic Stack
4.24 Summary
Exercises
Chapter 5 OOP Techniques: Interfaces and Polymorphism
5.1 Programming with Plug-Compatible Objects
5.2 Using Plug-Compatible Components
5.3 Planning Uniform Public Interfaces
5.4 Defining Interfaces
5.5 Implementing Interfaces
5.6 Why Interfaces?
5.7 Extending Interfaces
5.8 Abstract Superclass
5.9 Abstract Sequence
5.10 A Sequence of Dates
5.11 Ordering Text Lines
5.12 Interfaces versus Abstract Classes
5.13 Cloning Objects
5.14 Inheritance Planning
5.15 Summary
Exercises
Chapter 6 Packages and Core Classes
6.1 Packages
6.2 Java-Supplied Packages
6.3 Accessing Java Documentation
6.4 Input and Output
6.5 File I/O
6.6 Buffered I/O
6.7 Print Writers
6.8 Term Life Account Files
6.9 File Updating
6.10 Other I/O Streams
6.11 Textual and Unicode Character I/O
6.12 Noncharacter I/O
6.13 Object I/O
6.14 Number and Date Formatting
6.15 Error and Exception Handling
6.16 Matrix with Exceptions: An example
6.17 Character-Based Standard I/O and Error Reporting
6.18 Mathematical Computations
6.19 Date and Calendar
6.20 System and Environment Properties
6.21 Summary
Exercises
Chapter 7 Applets and Event-Driven Programming
7.1 About Networking
7.2 The Web
7.3 Web Pages and HTML
7.4 Applets
7.5 A First Applet
7.6 Testing and Deploying Applets
7.7 Browser Control of Applets
7.8 GUI Programming Basics
7.9 Event Handling
7.10 Tic Tac Toe
7.11 Sound Effects
7.12 Inner Classes
7.13 Applet Parameters
7.14 Applet Security Restrictions
7.15 Summary
Exercises
Chapter 8 GUI Programming
8.1 GUI Programming Overview
8.2 Widget Concepts
8.3 Swing Basics
8.4 Overview of Swing Widgets
8.5 Swing Widgets
8.6 Atomic Widgets
8.7 Text Input Widgets
8.8 Drawing Custom Graphics
8.9 Drawing Support
8.10 Raised Pie Chart
8.11 Layout Management
8.12 Using Dialogs
8.13 Using Menus
8.14 Event-Handling Notes
8.15 Applet-Application Dual-Purpose Programs
8.16 Summary
Exercises
Chapter 9 Generic Containers
9.1 Lists
9.2 Maps
9.3 Iterators
9.4 Sets
9.5 Collections Framework Interface Hierarchies
9.6 Framework Iterators
9.7 Functors
9.8 Generic Algorithms for Containers
9.9 Synchronized Containers
9.10 Read-Only Containers
9.11 Container Compatibility
9.12 Defining Custom Containers
9.13 Summary
Exercises
Chapter 10 Networking
10.1 Networking by URL
10.2 Creating and Manipulating URLs
10.3 Reading from a URL
10.4 Communicating with a URL
10.5 HTTP Basics
10.6 A URL Downloader
10.7 The POST Query
10.8 Query Body Encoding
10.9 A POST-Query Client
10.10 A Specific URL Client
10.11 Networking in Applets
10.12 CGI Scripts
10.13 Web Server-Side Programming
10.14 Network Communication with Sockets
10.15 Stream Socket Clients
10.16 Datagram Sockets
10.17 Creating Network Servers
10.18 Stream Socket Server Example
10.19 Remote Method Invocation
10.20 Summary
Exercises
Chapter 11 Threads and Concurrent Programming
11.1 What Is a Thread?
11.2 Threads in Java
11.3 Programming Threads
11.4 Launching Threads
11.5 Thread Control
11.6 Mutual Exclusion for Java Threads
11.7 Coordinating Threads
11.8 Consumer and Producer
11.9 I/O Between Two Threads
11.10 Thread Priorities
11.11 Terminating Thread Execution
11.12 Runnable Classes
11.13 Multithreaded GUI Applications
11.14 Timer with Images
11.15 Decoupled Image Loading and Drawing
11.16 Animation
11.17 AnimatorPanel
11.18 Animator Applet-Application
11.19 The Image Manager
11.20 Summary
Exercises
Chapter 12 Advanced Topics
12.1 Reflection
12.2 Dynamic Class Loading
12.3 The Java Run Time
12.4 Running Other Programs from Java
12.5 The Java Native Interface
12.6 JNI Example: Basic
12.7 JNI Example: Argument Passing
12.8 JNI Example: Strings
12.9 JNI Example: Arrays
12.10 Generating Java Documentation in HTML
12.11 Clipboards
12.12 Interapplet Communication
12.13 Java Security Manager
12.14 Signed Applets and Dynamic Trust Management
12.15 Summary
Exercises
Chapter 13 Object-Oriented Design
13.1 Decomposition Approaches
13.2 Object-Oriented Design Principles
13.3 Design Patterns
13.4 Unified Modeling Language (UML)
13.5 The CRC Method
13.6 Pocket Calculator Simulation
13.7 The MVC Design Pattern
13.8 Swing Widget Architecture and MVC
13.9 Summary
Exercises
Appendices
A Java Tools
B Java Keywords, Operators, and Packages
C Common Java Constructs
D Major Differences between Java and ANSI C/C++
E Layout Managers and Swing Widgets
F Colors in JFC
G Java I/O Classes
H Mathematical Computations
I The Java Debugger: jdb
J Index of Classes
K Basic Background