You are previewing Ivor Horton's Beginning Java®, Java 7 Edition.
O'Reilly logo
Ivor Horton's Beginning Java®, Java 7 Edition

Book Description

Ivor Horton's approach is teaching Java is so effective and popular that he is one of the leading authors of introductory programming tutorials, with over 160,000 copies of his Java books sold. In this latest edition, whether you're a beginner or an experienced programmer switching to Java, you'll learn how to build real-world Java applications using Java SE 7. The author thoroughly covers the basics as well as new features such as extensions and classes; extended coverage of the Swing Application Framework; and he does it all in his unique, highly accessible style that beginners love.

  • Provides a thorough introduction to the latest version of the Java programming language, Java SE 7

  • Introduces you to a host of new features for both novices and experienced programmers

  • Covers the basics as well as new language extensions and classes and class methods

  • Guides you through the Swing Application Framework for creating Swing apps

  • Uses numerous step-by-step programming examples to guide you through the development process

There's no better way to get thoroughly up to speed on the latest version of Java than with Ivor Horton's latest, comprehensive guide.

Table of Contents

  1. Cover
  2. Contents
  3. Chapter 1: 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
  4. Chapter 2: 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. The op= Operators
    7. Mathematical Functions and Constants
    8. Storing Characters
    9. Bitwise Operations
    10. Variables with a Fixed Set of Integer Values
    11. Boolean Variables
    12. Operator Precedence
    13. Program Comments
    14. Summary
  5. Chapter 3: 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
  6. Chapter 4: Arrays and Strings
    1. Arrays
    2. Strings
    3. Operations on Strings
    4. Mutable Strings
    5. Summary
  7. Chapter 5: 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. Summary
  8. Chapter 6: Extending Classes and Inheritance
    1. Using Existing Classes
    2. Class Inheritance
    3. The @Override Annotation
    4. Choosing Base Class Access Attributes
    5. Polymorphism
    6. Multiple Levels of Inheritance
    7. Abstract Classes
    8. The Universal Superclass
    9. Methods Accepting a Variable Number of Arguments
    10. Casting Objects
    11. More on Enumerations
    12. Designing Classes
    13. Using the final Modifier
    14. Interfaces
    15. Anonymous Classes
    16. Summary
  9. Chapter 7: Exceptions
    1. The Idea Behind Exceptions
    2. Types of Exceptions
    3. Dealing with Exceptions
    4. Exception Objects
    5. Defining Your Own Exceptions
    6. Summary
  10. Chapter 8: Understanding Streams
    1. Streams and Input/Output Operations
    2. Understanding Streams
    3. The Classes for Input and Output
    4. The Standard Streams
    5. Summary
  11. Chapter 9: Accessing Files and Directories
    1. Accessing the File System
    2. Working with Path Objects
    3. Creating and Deleting Directories and Files
    4. Getting the Contents of a Directory
    5. Closing a Stream
    6. Moving and Copying Files and Directories
    7. Summary
  12. Chapter 10: Writing Files
    1. File I/O Basics
    2. File Output
    3. Writing a File via an Output Stream
    4. Writing a File Using a Writer
    5. Buffers
    6. Writing a File Using a Channel
    7. File Write Operations
    8. Forcing Data to Be Written to a Device
    9. Summary
  13. Chapter 11: Reading Files
    1. File Read Operations
    2. Reading a File Using a Channel
    3. Copying Files
    4. Random Access to a File
    5. Memory-Mapped Files
    6. Summary
  14. Chapter 12: Serializing Objects
    1. Storing Objects in a File
    2. Writing an Object to a File
    3. Reading an Object from a File
    4. Summary
  15. Chapter 13: 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. Wildcards as Type Parameter Arguments
    6. Arrays and Parameterized Types
    7. Parameterized Methods
    8. Parameterized Types and Inheritance
    9. Summary
  16. Chapter 14: The Collections Framework
    1. Understanding the Collections Framework
    2. Collections of Objects
    3. Iterators
    4. Collection Classes
    5. Using EnumSet
    6. Array Collection Classes
    7. Linked Lists
    8. Using Maps
    9. Summary
  17. Chapter 15: 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
  18. Chapter 16: Threads
    1. Understanding Threads
    2. Managing Threads
    3. Using Executors
    4. Thread Priorities
    5. Summary
  19. Chapter 17: Creating Windows
    1. Graphical User Interfaces in Java
    2. Creating a Window
    3. Components and Containers
    4. Basics of Components
    5. Using Swing Containers
    6. Container Layout Managers
    7. Adding a Menu to a Window
    8. Summary
  20. Chapter 18: Handling Events
    1. Interactive Java Programs
    2. The Event-Handling Process
    3. Event Classes
    4. Semantic Event Handling in Applets
    5. Semantic Event Listeners in an Application
    6. Using Actions
    7. Adding a Toolbar
    8. Adding Menu Icons
    9. Adding Tooltips
    10. Disabling Actions
    11. Summary
  21. Chapter 19: Drawing in a Window
    1. Using the Model/View Architecture
    2. Component Coordinate Systems
    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. Changing the Cursor
    10. Summary
  22. Chapter 20: Extending the GUI
    1. Creating a Status Bar
    2. Using Dialogs
    3. Using a Dialog to Create Text Elements
    4. A Font Selection Dialog
    5. Pop-Up Menus
    6. Transforming the User Coordinate System
    7. Choosing Custom Colors
    8. Summary
  23. Chapter 21: Filing and Printing Documents
    1. Serializing the Sketch
    2. Basic Infrastructure for Saving Sketches
    3. Using a File Chooser
    4. Implementing File Operations
    5. Printing in Java
    6. Summary
  24. Chapter 22: 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. A Schema for Sketcher
    9. Programming with XML Documents
    10. Accessing Parsers
    11. Using SAX
    12. Summary
  25. Chapter 23: Creating and Modifying XML Documents
    1. The Document Object Model
    2. Setting DOM Parser Features
    3. Parsing a Document
    4. Navigating a Document Object Tree
    5. Transforming XML
    6. Creating Document Objects
    7. Storing a Sketch as XML
    8. Reading an XML Representation of a Sketch
    9. Summary
  26. Appendix A: Keywords
  27. Appendix B: Computer Arithmetic