You are previewing Ivor Horton's Beginning Java™ 2, JDK™ 5th Edition.
O'Reilly logo
Ivor Horton's Beginning Java™ 2, JDK™ 5th Edition

Book Description

What is this book about?

This book is a comprehensive introduction to the Java programming language, updated thoroughly (more than 35ew and updated) for the latest SDK 1.5 release. This book shows readers how to build real-world Java applications using the Java SDK. No previous programming experience is required. The author uses numerous step-by-step programming examples to guide readers through the ins and outs of Java development. In addition to fully covering new features of SDK 1.5, such as generic types, the author has also added new chapters on Java database programming with JDBC and Java programming with XML.

Table of Contents

  1. Copyright
  2. About the Author
  3. Credits
  4. Foreword
  5. Acknowledgments
  6. Introduction
  7. Introducing Java
    1. What Is Java All About?
    2. Features of The Java Language
    3. Learning Java
    4. The Java Environment
    5. Object-Oriented Programming in Java
    6. Java Program Structure
    7. Java and Unicode
    8. Summary
    9. Resources
  8. Programs, Data, Variables, and Calculation
    1. Data and Variables
    2. Integer Data Types
    3. Floating-Point Data Types
    4. Fixing the Value of a Variable
    5. Arithmetic Calculations
    6. Mixed Arithmetic Expressions
    7. The op= Operators
    8. Mathematical Functions and Constants
    9. Storing Characters
    10. Bitwise Operations
    11. Variables with a Fixed Set of Integer Values
    12. Boolean Variables
    13. Operator Precedence
    14. Program Comments
    15. Summary
    16. Exercises
  9. Loops and Logic
    1. Making Decisions
    2. Logical Operators
    3. The Conditional Operator
    4. The switch Statement
    5. Variable Scope
    6. Loops
    7. Assertions
    8. Summary
    9. Exercises
  10. Arrays and Strings
    1. Arrays
    2. Strings
    3. Operations on Strings
    4. Mutable Strings
    5. Summary
    6. Exercises
  11. Defining Classes
    1. What Is a Class?
    2. Defining Classes
    3. Defining Methods
    4. Constructors
    5. Defining and Using a Class
    6. Method Overloading
    7. Using Objects
    8. Recursion
    9. Understanding Packages
    10. Controlling Access to Class Members
    11. Nested Classes
    12. The finalize() Method
    13. Native Methods
    14. Summary
    15. Exercises
  12. Extending Classes and Inheritance
    1. Using Existing Classes
    2. Class Inheritance
    3. Choosing Base Class Access Attributes
    4. Polymorphism
    5. Multiple Levels of Inheritance
    6. Abstract Classes
    7. The Universal Superclass
    8. Methods Accepting a Variable Number of Arguments
    9. Casting Objects
    10. More on Enumerations
    11. Designing Classes
    12. Using the final Modifier
    13. Interfaces
    14. Anonymous Classes
    15. Summary
    16. Exercises
  13. Exceptions
    1. The Idea Behind Exceptions
    2. Types of Exceptions
    3. Dealing with Exceptions
    4. Exception Objects
    5. Defining Your Own Exceptions
    6. Summary
    7. Exercises
  14. Understanding Streams
    1. Streams and the New I/O Capability
    2. Understanding Streams
    3. The Classes for Input and Output
    4. The Standard Streams
    5. Summary
    6. Exercises
  15. Accessing Files and Directories
    1. Working with File Objects
    2. Creating File Output Streams
    3. Summary
    4. Exercises
  16. Writing Files
    1. File I/O Basics
    2. File Input and Output
    3. Channels
    4. Buffers
    5. Writing to a File
    6. Summary
    7. Exercises
  17. Reading Files
    1. File Read Operations
    2. File Channel Read Operations
    3. Reading a Text File
    4. Reading Binary Data
    5. Reading Mixed Data
    6. Copying Files
    7. Random Access to a File
    8. Read/Write Operations with a Single File Channel
    9. Memory-Mapped Files
    10. Summary
    11. Exercises
  18. Serializing Objects
    1. Storing Objects in a File
    2. Summary
    3. Exercises
  19. Generic Class Types
    1. What Are Generic Types?
    2. Defining a Generic Class Type
    3. Generic Types and Generic Interfaces
    4. Variables of a Raw Type
    5. Using Wildcards as Type Parameter Arguments
    6. Arrays and Parameterized Types
    7. Parameterized Methods
    8. Parameterized Types and Inheritance
    9. Summary
    10. Exercises
  20. The Collections Framework
    1. Understanding the Collections Framework
    2. Collections of Objects
    3. Iterators
    4. Collection Classes
    5. Using Vectors
    6. Linked Lists
    7. Using Maps
    8. Summary
    9. Exercises
  21. A Collection of Useful Classes
    1. Utility Methods for Arrays
    2. Observable and Observer Objects
    3. Generating Random Numbers
    4. Dates and Times
    5. Regular Expressions
    6. Using a Scanner
    7. Summary
    8. Exercises
  22. Threads
    1. Understanding Threads
    2. Managing Threads
    3. Thread Priorities
    4. Summary
    5. Exercises
  23. Creating Windows
    1. Graphical User Interfaces in Java
    2. Creating a Window
    3. Components and Containers
    4. Basics of Components
    5. Using Containers
    6. Container Layout Managers
    7. Adding a Menu to a Window
    8. More on Applets
    9. Summary
    10. Exercises
  24. Handling Events
    1. Window-Based Java Programs
    2. The Event-Handling Process
    3. Avoiding Deadlocks in GUI Code
    4. Event Classes
    5. Semantic Event Handling in Applets
    6. Semantic Event Listeners in an Application
    7. Using Actions
    8. Adding a Toolbar
    9. Summary
    10. Exercises
  25. Drawing in a Window
    1. Using the Model/View Architecture
    2. Coordinate Systems in Components
    3. Drawing on a Component
    4. Shapes
    5. Filling Shapes
    6. Managing Shapes
    7. Drawing Using the Mouse
    8. Defining Your Own Shape Classes
    9. Summary
    10. Exercises
  26. Extending the GUI
    1. Creating a Status Bar
    2. Using Dialogs
    3. Pop-Up Menus
    4. Transforming the User Coordinate System
    5. Choosing Custom Colors
    6. Summary
    7. Exercises
  27. Filing and Printing Documents
    1. Serializing the Sketch
    2. Implementing the Serializable Interface
    3. Supporting the File Menu
    4. Printing in Java
    5. Summary
    6. Exercises
  28. Java and XML
    1. XML
    2. XML Document Structure
    3. Data Structure in XML
    4. Document Type Definitions
    5. Rules for a Well-Formed Document
    6. XML Namespaces
    7. XML Schemas
    8. Programming with XML Documents
    9. Accessing Parsers
    10. Using SAX
    11. Summary
    12. Exercises
  29. Creating and Modifying XML Documents
    1. The Document Object Model (DOM)
    2. Summary
    3. Exercises
  30. Talking to Databases
    1. JDBC Concepts and Terminology
    2. Introducing SQL
    3. The JDBC Package
    4. The Essential JDBC Program
    5. Using a PreparedStatement Object
    6. Creating an Interactive SQL Tool
    7. Summary
    8. Exercises
  31. The JDBC in Action
    1. Data Types and JDBC
    2. Mapping Relational Data onto Java Objects
    3. The Statement and PreparedStatement Interfaces
    4. The ResultSet
    5. Calling Procedures
    6. Handling Errors
    7. Browsing a Database
    8. Summary
    9. Exercises
  32. Keywords
  33. Computer Arithmetic
    1. Binary Numbers
    2. Floating-Point Numbers
  34. Index