You are previewing The Java™ Tutorial Fourth Edition: A Short Course on the Basics.
O'Reilly logo
The Java™ Tutorial Fourth Edition: A Short Course on the Basics

Book Description

A hands-on guide to the Java programming language, The Java™ Tutorial, Fourth Edition is perfect for any developer looking for a proven path to proficiency with Java SE. This popular tutorial "from the Source" has been completely revised and updated to cover Version 6 of the Java Platform, Standard Edition.

Written by members of the Java Software team at Sun Microsystems, this book uses a tested, interactive approach and features real-world problems that help you learn the Java platform by example.

New to this edition are chapters on generics, collections, Java Web Start, the platform environment, and regular expressions. Key sections, including the Threads, I/O, Object-Oriented Programming Concepts, and Language Basics chapters have been completely rewritten to reflect reader feedback and to cover new features added to the Java SE 6 platform. A new appendix contains information on how to prepare for the Java Programming Language Certification exam.

As with the previous editions, you will find clear explanations of the fundamentals of objects, classes, and data structures, as well as detailed coverage of exceptions, I/O, and threads. All of the popular features that made this book a classic have been retained, including convenient summaries at the end of each section and Questions and Exercises segments to help you practice what you learn.

The accompanying CD-ROM is filled with valuable resources including the latest Java SE software (the JRE, JDK, Java API spec, and the guide documentation), the code samples from this book, and solutions to the questions and exercises.

The Java™ Series is supported, endorsed, and authored by the creators of the Java technology at Sun Microsystems, Inc. It is the official place to go for complete, expert, and definitive information on Java technology. The books in this series provide the inside information you need to build effective, robust, and portable applications and applets. The Series is an indispensable resource for anyone targeting the Java™ platform.



Table of Contents

  1. Copyright
  2. The Java™ Series
  3. Foreword
  4. Preface
    1. Who Should Read This Book?
    2. How to Use This Book
    3. Acknowledgments
    4. About the Authors
  5. 1. Getting Started
    1. The Java Technology Phenomenon
      1. About the Java Technology
        1. The Java Programming Language
        2. The Java Platform
      2. What Can Java Technology Do?
      3. How Will Java Technology Change My Life?
    2. The “Hello World!” Application
      1. “Hello World!” for the NetBeans IDE
        1. A Checklist
        2. Creating Your First Application
          1. Create an IDE Project
          2. Add Code to the Generated Source File
          3. Compile the Source File into a .class File
          4. Run the Program
        3. Continuing the Tutorial with the NetBeans IDE
      2. “Hello World!” for Microsoft Windows
        1. A Checklist
        2. Creating Your First Application
          1. Create a Source File
          2. Compile the Source File into a .class File
          3. Run the Program
      3. “Hello World!” for Solaris OS and Linux
        1. A Checklist
        2. Creating Your First Application
          1. Create a Source File
          2. Compile the Source File into a .class File
          3. Run the Program
    3. A Closer Look at the “Hello World!” Application
      1. Source Code Comments
      2. The HelloWorldApp Class Definition
      3. The main Method
    4. Common Problems (and Their Solutions)
      1. Compiler Problems
        1. Common Error Messages on Microsoft Windows Systems
        2. Common Error Messages on UNIX Systems
        3. Syntax Errors (All Platforms)
        4. Semantic Errors
      2. Runtime Problems
        1. Error Messages on Microsoft Windows Systems
        2. Error Messages on UNIX Systems
        3. The main Method Is Not Defined
    5. Questions and Exercises: Getting Started
      1. Questions
      2. Exercises
      3. Answers
  6. 2. Object-Oriented Programming Concepts
    1. What Is an Object?
    2. What Is a Class?
    3. What Is Inheritance?
    4. What Is an Interface?
    5. What Is a Package?
    6. Questions and Exercises: Object-Oriented Programming Concepts
      1. Questions
      2. Exercises
      3. Answers
  7. 3. Language Basics
    1. Variables
      1. Naming
      2. Primitive Data Types
        1. Default Values
        2. Literals
      3. Arrays
        1. Declaring a Variable to Refer to an Array
        2. Creating, Initializing, and Accessing an Array
        3. Copying Arrays
      4. Summary of Variables
      5. Questions and Exercises: Variables
        1. Questions
        2. Exercises
        3. Answers
    2. Operators
      1. Assignment, Arithmetic, and Unary Operators
        1. The Simple Assignment Operator
        2. The Arithmetic Operators
        3. The Unary Operators
      2. Equality, Relational, and Conditional Operators
        1. The Equality and Relational Operators
        2. The Conditional Operators
        3. The Type Comparison Operator instanceof
      3. Bitwise and Bit Shift Operators
      4. Summary of Operators
      5. Questions and Exercises: Operators
        1. Questions
        2. Exercises
        3. Answers
    3. Expressions, Statements, and Blocks
      1. Expressions
      2. Statements
      3. Blocks
      4. Questions and Exercises: Expressions, Statements, and Blocks
        1. Questions
        2. Exercises
        3. Answers
    4. Control Flow Statements
      1. The if-then and if-then-else Statements
        1. The if-then Statement
        2. The if-then-else Statement
      2. The switch Statement
      3. The while and do-while Statements
      4. The for Statement
      5. Branching Statements
        1. The break Statement
        2. The continue Statement
        3. The return Statement
      6. Summary of Control Flow Statements
      7. Questions and Exercises: Control Flow Statements
        1. Questions
        2. Exercises
        3. Answers
  8. 4. Classes and Objects
    1. Classes
      1. Declaring Classes
      2. Declaring Member Variables
        1. Access Modifiers
        2. Types
        3. Variable Names
      3. Defining Methods
        1. Naming a Method
        2. Overloading Methods
      4. Providing Constructors for Your Classes
      5. Passing Information to a Method or a Constructor
        1. Parameter Types
        2. Arbitrary Number of Arguments
        3. Parameter Names
        4. Passing Primitive Data Type Arguments
        5. Passing Reference Data Type Arguments
    2. Objects
      1. Creating Objects
        1. Declaring a Variable to Refer to an Object
        2. Instantiating a Class
        3. Initializing an Object
      2. Using Objects
        1. Referencing an Object’s Fields
        2. Invoking an Object’s Methods
        3. The Garbage Collector
    3. More on Classes
      1. Returning a Value from a Method
        1. Returning a Class or Interface
      2. Using the this Keyword
        1. Using this with a Field
        2. Using this with a Constructor
      3. Controlling Access to Members of a Class
      4. Understanding Instance and Class Members
        1. Class Variables
        2. Class Methods
        3. Constants
        4. The Bicycle Class
      5. Initializing Fields
        1. Static Initialization Blocks
        2. Initializing Instance Members
      6. Summary of Creating and Using Classes and Objects
      7. Questions and Exercises: Classes
        1. Questions
        2. Exercises
        3. Answers
      8. Questions and Exercises: Objects
        1. Questions
        2. Exercises
        3. Answers
    4. Nested Classes
      1. Why Use Nested Classes?
      2. Static Nested Classes
      3. Inner Classes
      4. Inner Class Example
        1. Local and Anonymous Inner Classes
        2. Modifiers
      5. Summary of Nested Classes
      6. Questions and Exercises: Nested Classes
        1. Questions
        2. Exercises
        3. Answers
    5. Enum Types
      1. Questions and Exercises: Enum Types
        1. Exercises
        2. Answers
    6. Annotations
      1. Documentation
      2. Annotations Used by the Compiler
      3. Annotation Processing
      4. Questions and Exercises: Annotations
        1. Questions
        2. Answers
  9. 5. Interfaces and Inheritance
    1. Interfaces
      1. Interfaces in Java
      2. Interfaces as APIs
      3. Interfaces and Multiple Inheritance
      4. Defining an Interface
        1. The Interface Body
      5. Implementing an Interface
        1. A Sample Interface, Relatable
        2. Implementing the Relatable Interface
      6. Using an Interface as a Type
      7. Rewriting Interfaces
      8. Summary of Interfaces
      9. Questions and Exercises: Interfaces
        1. Questions
        2. Exercises
        3. Answers
    2. Inheritance
      1. The Java Platform Class Hierarchy
      2. An Example of Inheritance
      3. What You Can Do in a Subclass
      4. Private Members in a Superclass
      5. Casting Objects
      6. Overriding and Hiding Methods
        1. Instance Methods
        2. Class Methods
        3. Modifiers
        4. Summary
      7. Hiding Fields
      8. Using the Keyword super
        1. Accessing Superclass Members
        2. Subclass Constructors
      9. Object as a Superclass
        1. The clone() Method
        2. The equals() Method
        3. The finalize() Method
        4. The getClass() Method
        5. The hashCode() Method
        6. The toString() Method
      10. Writing Final Classes and Methods
      11. Abstract Methods and Classes
        1. Abstract Classes versus Interfaces
        2. An Abstract Class Example
        3. When an Abstract Class Implements an Interface
        4. Class Members
      12. Summary of Inheritance
      13. Questions and Exercises: Inheritance
        1. Questions
        2. Exercises
        3. Answers
  10. 6. Generics
    1. Introduction
      1. A Simple Box Class
    2. Generic Types
      1. Type Parameter Conventions
    3. Generic Methods and Constructors
    4. Bounded Type Parameters
    5. Subtyping
    6. Wildcards
    7. Type Erasure
    8. Summary of Generics
    9. Questions and Exercises: Generics
      1. Questions
      2. Exercises
      3. Answers
  11. 7. Packages
    1. Creating and Using Packages
      1. Creating a Package
      2. Naming a Package
        1. Naming Conventions
      3. Using Package Members
        1. Referring to a Package Member by its Qualified Name
        2. Importing a Package Member
        3. Importing an Entire Package
        4. Apparent Hierarchies of Packages
        5. Name Ambiguities
        6. The Static Import Statement
      4. Managing Source and Class Files
        1. Setting the CLASSPATH System Variable
      5. Summary of Creating and Using Packages
      6. Questions and Exercises: Creating and Using Packages
        1. Questions
        2. Exercises
        3. Answers
  12. 8. Numbers and Strings
    1. Numbers
      1. The Numbers Classes
      2. Formatting Numeric Print Output
        1. The printf() and format() Methods
        2. An Example
        3. The DecimalFormat Class
      3. Beyond Basic Arithmetic
        1. Constants and Basic Methods
        2. Exponential and Logarithmic Methods
        3. Trigonometric Methods
        4. Random Numbers
      4. Summary of Numbers
      5. Questions and Exercises: Numbers
        1. Questions
        2. Exercises
        3. Answers
    2. Characters
      1. Escape Sequences
    3. Strings
      1. Creating Strings
      2. String Length
      3. Concatenating Strings
      4. Creating Format Strings
      5. Converting Between Numbers and Strings
        1. Converting Strings to Numbers
        2. Converting Numbers to Strings
      6. Manipulating Characters in a String
        1. Getting Characters and Substrings by Index
        2. Other Methods for Manipulating Strings
        3. Searching for Characters and Substrings in a String
        4. Replacing Characters and Substrings into a String
        5. An Example
      7. Comparing Strings and Portions of Strings
      8. The StringBuilder Class
        1. Length and Capacity
        2. StringBuilder Operations
        3. An Example
      9. Summary of Characters and Strings
      10. Questions and Exercises: Characters and Strings
        1. Questions
        2. Exercises
        3. Answers
  13. 9. Exceptions
    1. What Is an Exception?
    2. The Catch or Specify Requirement
      1. The Three Kinds of Exceptions
      2. Bypassing Catch or Specify
    3. Catching and Handling Exceptions
      1. The try Block
      2. The catch Blocks
      3. The finally Block
      4. Putting It All Together
        1. Scenario 1: An Exception Occurs
        2. Scenario 2: The try Block Exits Normally
    4. Specifying the Exceptions Thrown by a Method
    5. How to Throw Exceptions
      1. The throw Statement
      2. Throwable Class and Its Subclasses
      3. Error Class
      4. Exception Class
      5. Chained Exceptions
        1. Accessing Stack Trace Information
        2. Logging API
      6. Creating Exception Classes
        1. An Example
        2. Choosing a Superclass
    6. Unchecked Exceptions—The Controversy
    7. Advantages of Exceptions
      1. Advantage 1: Separating Error-Handling Code from “Regular” Code
      2. Advantage 2: Propagating Errors Up the Call Stack
      3. Advantage 3: Grouping and Differentiating Error Types
    8. Summary
    9. Questions and Exercises: Exceptions
      1. Questions
      2. Exercises
      3. Answers
  14. 10. Basic I/O
    1. I/O Streams
      1. Byte Streams
        1. Using Byte Streams
        2. Always Close Streams
        3. When Not to Use Byte Streams
      2. Character Streams
        1. Using Character Streams
        2. Character Streams That Use Byte Streams
        3. Line-Oriented I/O
      3. Buffered Streams
        1. Flushing Buffered Streams
      4. Scanning and Formatting
        1. Scanning
          1. Breaking Input into Tokens
          2. Translating Individual Tokens
        2. Formatting
          1. The print and println Methods
          2. The format Method
      5. I/O from the Command Line
        1. Standard Streams
        2. The Console
          1. readPassword
      6. Data Streams
      7. Object Streams
        1. Output and Input of Complex Objects
    2. File I/O
      1. File Objects
        1. A File Has Many Names
        2. Manipulating Files
        3. Working with Directories
        4. Static Methods
      2. Random Access Files
    3. The New I/O Packages
    4. Summary
    5. Questions and Exercises: Basic I/O
      1. Questions
      2. Exercises
      3. Answers
  15. 11. Collections
    1. Introduction to Collections
      1. What Is a Collections Framework?
      2. Benefits of the Java Collections Framework
        1. Reduces Programming Effort
        2. Increases Program Speed and Quality
        3. Allows Interoperability among Unrelated APIs
        4. Reduces Effort to Learn and to Use New APIs
        5. Reduces Effort to Design New APIs
        6. Fosters Software Reuse
    2. Interfaces
      1. The Collection Interface
        1. Traversing Collections
          1. for-each Construct
          2. Iterators
        2. Collection Interface Bulk Operations
        3. Collection Interface Array Operations
      2. The Set Interface
        1. Set Interface Basic Operations
        2. Set Interface Bulk Operations
        3. Set Interface Array Operations
      3. The List Interface
        1. Comparison to Vector
        2. Collection Operations
        3. Positional Access and Search Operations
        4. Iterators
        5. Range-View Operation
        6. List Algorithms
      4. The Queue Interface
      5. The Map Interface
        1. Comparison to Hashtable
        2. Map Interface Basic Operations
        3. Map Interface Bulk Operations
        4. Collection Views
        5. Fancy Uses of Collection Views: Map Algebra
        6. Multimaps
      6. Object Ordering
        1. Writing Your Own Comparable Types
        2. Comparators
      7. The SortedSet Interface
        1. Set Operations
        2. Standard Constructors
        3. Range-view Operations
        4. Endpoint Operations
        5. Comparator Accessor
      8. The SortedMap Interface
        1. Map Operations
        2. Standard Constructors
        3. Comparison to SortedSet
      9. Summary of Interfaces
      10. Questions and Exercises: Interfaces
        1. Questions
        2. Exercises
        3. Answers
    3. Implementations
      1. Set Implementations
        1. General-Purpose Set Implementations
        2. Special-Purpose Set Implementations
      2. List Implementations
        1. General-Purpose List Implementations
        2. Special-Purpose List Implementations
      3. Map Implementations
        1. General-Purpose Map Implementations
        2. Special-Purpose Map Implementations
        3. Concurrent Map Implementations
      4. Queue Implementations
        1. General-Purpose Queue Implementations
        2. Concurrent Queue Implementations
      5. Wrapper Implementations
        1. Synchronization Wrappers
        2. Unmodifiable Wrappers
        3. Checked Interface Wrappers
      6. Convenience Implementations
        1. List View of an Array
        2. Immutable Multiple-Copy List
        3. Immutable Singleton Set
        4. Empty Set, List, and Map Constants
      7. Summary of Implementations
      8. Questions and Exercises: Implementations
        1. Questions
        2. Exercises
        3. Answers
    4. Algorithms
      1. Sorting
      2. Shuffling
      3. Routine Data Manipulation
      4. Searching
      5. Composition
      6. Finding Extreme Values
    5. Custom Collection Implementations
      1. Reasons to Write an Implementation
      2. How to Write a Custom Implementation
    6. Interoperability
      1. Compatibility
        1. Upward Compatibility
        2. Backward Compatibility
      2. API Design
        1. Parameters
        2. Return Values
        3. Legacy APIs
  16. 12. Concurrency
    1. Processes and Threads
      1. Processes
      2. Threads
    2. Thread Objects
      1. Defining and Starting a Thread
      2. Pausing Execution with sleep
      3. Interrupts
        1. Supporting Interruption
        2. The Interrupt Status Flag
      4. Joins
      5. The SimpleThreads Example
    3. Synchronization
      1. Thread Interference
      2. Memory Consistency Errors
      3. Synchronized Methods
      4. Intrinsic Locks and Synchronization
        1. Locks In Synchronized Methods
        2. Synchronized Statements
        3. Reentrant Synchronization
      5. Atomic Access
    4. Liveness
      1. Deadlock
      2. Starvation and Livelock
        1. Starvation
        2. Livelock
    5. Guarded Blocks
    6. Immutable Objects
      1. A Synchronized Class Example
      2. A Strategy for Defining Immutable Objects
    7. High-Level Concurrency Objects
      1. Lock Objects
      2. Executors
        1. Executor Interfaces
          1. The Executor Interface
          2. The ExecutorService Interface
          3. The ScheduledExecutorService Interface
        2. Thread Pools
      3. Concurrent Collections
      4. Atomic Variables
    8. For Further Reading
    9. Questions and Exercises: Concurrency
      1. Questions
      2. Exercises
      3. Answers
  17. 13. Regular Expressions
    1. Introduction
      1. What Are Regular Expressions?
      2. How Are Regular Expressions Represented in This Package?
    2. Test Harness
    3. String Literals
      1. Metacharacters
    4. Character Classes
      1. Simple Classes
        1. Negation
        2. Ranges
        3. Unions
        4. Intersections
        5. Subtraction
    5. Predefined Character Classes
    6. Quantifiers
      1. Zero-Length Matches
      2. Capturing Groups and Character Classes with Quantifiers
      3. Differences among Greedy, Reluctant, and Possessive Quantifiers
    7. Capturing Groups
      1. Numbering
      2. Backreferences
    8. Boundary Matchers
    9. Methods of the Pattern Class
      1. Creating a Pattern with Flags
      2. Embedded Flag Expressions
      3. Using the matches(String,CharSequence) Method
      4. Using the split(String) Method
      5. Other Utility Methods
      6. Pattern Method Equivalents in java.lang.String
    10. Methods of the Matcher Class
      1. Index Methods
      2. Study Methods
      3. Replacement Methods
      4. Using the start and end Methods
      5. Using the matches and lookingAt Methods
      6. Using replaceFirst(String) and replaceAll(String)
      7. The appendReplacement(StringBuffer,String) and appendTail(StringBuffer) Methods
      8. Matcher Method Equivalents in java.lang.String
    11. Methods of the PatternSyntaxException Class
    12. Summary
    13. Additional Resources
    14. Questions and Exercises: Regular Expressions
      1. Questions
      2. Exercises
      3. Answers
  18. 14. The Platform Environment
    1. Configuration Utilities
      1. Properties
        1. Properties in the Application Life Cycle
        2. Setting Up the Properties Object
        3. Saving Properties
        4. Getting Property Information
        5. Setting Properties
      2. Command-Line Arguments
        1. Echoing Command-Line Arguments
        2. Parsing Numeric Command-Line Arguments
      3. Environment Variables
        1. Querying Environment Variables
        2. Passing Environment Variables to New Processes
        3. Platform Dependency Issues
      4. Other Configuration Utilities
    2. System Utilities
      1. Command-Line I/O Objects
      2. System Properties
        1. Reading System Properties
        2. Writing System Properties
      3. The Security Manager
        1. Interacting with the Security Manager
        2. Recognizing a Security Violation
      4. Miscellaneous Methods in System
    3. PATH and CLASSPATH
      1. Update the PATH Variable (Microsoft Windows NT/2000/XP)
      2. Update the PATH Variable (Solaris and Linux)
      3. Checking the CLASSPATH Variable (All Platforms)
    4. Questions and Exercises: The Platform Environment
      1. Questions
      2. Exercises
      3. Answers
  19. 15. Swing
    1. A Brief Introduction to the Swing Package
      1. What Is Swing?
        1. Swing GUI Components
        2. Java 2D API
        3. Pluggable Look-and-Feel Support
        4. Data Transfer
        5. Internationalization
        6. Accessibility API
        7. Undo Framework API
        8. Flexible Deployment Support
      2. A Swing Demo
        1. Host Info
          1. List View
          2. Table View
        2. Details/Notes Tabbed Pane
          1. Details Panel
          2. Notes Text Pane
        3. Wizzy 2D Graphics
        4. Multiple Look and Feels
        5. Undo and Redo
    2. Swing Features
      1. A Visual Guide to Swing Components
        1. Basic Controls (Table 15.1)
        2. Interactive Displays of Highly Formatted Information (Table 15.2)
        3. Uneditable Information Displays (Table 15.3)
        4. Top-Level Containers (Table 15.4)
        5. General-Purpose Containers (Table 15.5)
        6. Special-Purpose Containers (Table 15.6)
      2. Pluggable Look and Feel
      3. Drag and Drop and Data Transfer
        1. Drag and Drop
        2. Cut, Copy, and Paste
      4. Internationalization and Localization
      5. Accessibility
      6. Integrating with the Desktop
      7. System Tray Icon Support
    3. Questions: Graphical User Interfaces
      1. Questions
      2. Answers
  20. 16. Packaging Programs in JAR Files
    1. Using JAR Files: The Basics
      1. Creating a JAR File
        1. An Example
      2. Viewing the Contents of a JAR File
        1. An Example
      3. Extracting the Contents of a JAR File
        1. An Example
      4. Updating a JAR File
        1. Examples
      5. Running JAR-Packaged Software
        1. Applets Packaged in JAR Files
        2. JAR Files as Applications
    2. Working with Manifest Files: The Basics
      1. Understanding the Default Manifest
      2. Modifying a Manifest File
      3. Setting an Application's Entry Point
        1. An Example
        2. Setting an Entry Point with the JAR Tool
      4. Adding Classes to the JAR File’s Classpath
        1. An Example
      5. Setting Package Version Information
        1. An Example
      6. Sealing Packages Within a JAR File
        1. An Example
        2. Sealing JAR Files
    3. Signing and Verifying JAR Files
      1. Understanding Signing and Verification
        1. Digests and the Signature File
        2. The Signature Block File
        3. Related Documentation
      2. Signing JAR Files
        1. Example
        2. Additional Information
      3. Verifying Signed JAR Files
    4. Using JAR-Related APIs
      1. An Example—The JarRunner Application
      2. The JarClassLoader Class
        1. The JarClassLoader Constructor
        2. The getMainClassName Method
          1. The JarURLConnection Class and JAR URLs
          2. The java.net.JarURLConnection Class
          3. Fetching Manifest Attributes: java.util.jar.Attributes
        3. The invokeClass Method
      3. The JarRunner Class
    5. Questions: JAR Files
      1. Questions
      2. Answers
  21. 17. Java Web Start
    1. Running Java Web Start Applications
      1. Running a Java Web Start Application from a Browser
      2. Running an Application from the Java Cache Viewer
      3. Running a Java Web Start Application from the Desktop
    2. Deploying Java Web Start Applications
      1. Setting Up the Web Server
      2. Creating the JNLP File
        1. An Example JNLP File
        2. JNLP File Contents
        3. Encoding JNLP Files
      3. Placing the Application on the Web Server
      4. Creating the Web Page
        1. Adding the Basic Link to the JNLP File
        2. Adding the Link When Java Web Start Is Not Installed
    3. Developing Java Web Start Applications
      1. Packaging the Application in JAR Files
      2. Reading Resources in a JAR File
      3. Untrusted Applications
    4. The JNLP API
    5. Java Web Start and Security
      1. Java Web Start Security Basics
      2. Signing JAR Files for Java Web Start Deployment
      3. Security and JNLP Files
      4. Dynamic Downloading of HTTPS Certificates
    6. Common Java Web Start Problems
    7. Questions and Exercises: Java Web Start
      1. Questions
      2. Exercises
      3. Answers
  22. 18. Applets
    1. Getting Started with Applets
      1. Extending Applet or JApplet
      2. The Life Cycle of an Applet
        1. Loading the Applet
        2. Leaving and Returning to the Applet’s Page
        3. Reloading the Applet
        4. Quitting the Browser
        5. Summary
      3. Methods for Milestones
        1. Overriding These Methods
        2. The init Method
        3. The start Method
        4. The stop Method
        5. The destroy Method
      4. Methods for Drawing and Event Handling
        1. Using the paint Method
        2. Handling Events
      5. Methods for Adding UI Components
        1. Pre-Made UI Components
        2. Methods for Using UI Components in Applets
        3. Adding a Non-Editable Text Field to the Simple Applet
      6. What Applets Can and Can’t Do
        1. Security Restrictions
        2. Applet Capabilities
    2. Taking Advantage of the Applet API
      1. Finding and Loading Data Files
      2. Displaying Short Status Strings
      3. Displaying Documents in the Browser
      4. Sending Messages to Other Applets
        1. Finding an Applet by Name: The getApplet Method
        2. Finding All the Applets on a Page: The getApplets Method
      5. Playing Sounds
        1. Sound-Related Methods
        2. An Example
      6. Defining and Using Applet Parameters
        1. Deciding Which Parameters to Support
          1. What Should the Applet Let the User Configure?
          2. What Should the Parameters Be Named?
          3. What Kind of Value Should Each Parameter Take?
          4. What Should the Default Value of Each Parameter Be?
          5. An Example: A Sample <APPLET> Tag
        2. Writing the Code to Support Parameters
        3. Giving Information about Parameters
      7. Using the APPLET Tag
        1. Specifying Parameters
        2. Specifying Alternate HTML Code and Text
        3. Specifying the Applet Directory
        4. Combining an Applet’s Files into a Single File
        5. Other <APPLET> Tag Attributes
    3. Practical Considerations When Writing Applets
      1. Security Restrictions
      2. Creating a User Interface
        1. Creating a GUI
        2. Displaying Diagnostics to the Standard Output and Error Streams
      3. Getting System Properties
        1. System Properties That Applets Can Read
        2. Forbidden System Properties
      4. Threads in Applets
        1. Threads in Applets: Examples
          1. Using a Thread to Perform Repeated Tasks
          2. Using a Thread to Perform One-Time Initialization
      5. Working with a Server-Side Application
        1. A Simple Network Client Applet
        2. Using a Server to Work Around Security Restrictions
    4. Finishing an Applet
      1. Before You Ship That Applet
      2. The Perfectly Finished Applet
    5. Deploying Applets
      1. General Deployment Considerations
        1. Deploying Applets on the Internet versus an Intranet
        2. Deploying Applets for Specific Browsers
      2. Using the applet Tag
      3. Using the object Tag
        1. The classid Attribute
        2. The codebase Attribute
      4. Using the embed Tag
      5. Deploying Applets in a Mixed-Browser Environment
        1. Using Pure HTML
        2. Using JavaScript
    6. Solving Common Applet Problems
    7. Questions and Exercises: Java Applets
      1. Questions
      2. Exercises
      3. Answers
  23. A. Java Language Keywords
  24. B. Preparation for Java Programming Language Certification
    1. Section 1: Declarations, Initialization and Scoping
      1. Item 1
      2. Item 2
      3. Item 3
      4. Item 4
      5. Item 5
      6. Item 6
    2. Section 2: Flow Control
      1. Item 1
      2. Item 2
      3. Item 3
      4. Item 4
      5. Item 5
      6. Item 6
    3. Section 3: API Contents
      1. Item 1
      2. Item 2
      3. Item 3
      4. Item 4
      5. Item 5
    4. Section 4: Concurrency
      1. Item 1
      2. Item 2
      3. Item 3
      4. Item 4
    5. Section 5: OO Concepts
      1. Item 1
      2. Item 2
      3. Item 3
      4. Item 4
      5. Item 5
    6. Section 6: Collections / Generics
      1. Item 1
      2. Item 2
      3. Item 3
      4. Item 4
      5. Item 5
    7. Section 7: Fundamentals
      1. Item 1
      2. Item 2
      3. Item 3
      4. Item 4
      5. Item 5
      6. Item 6
  25. The Java Tutorial CD