O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Java How to Program (early objects), 9/e

Book Description

The Deitels’ groundbreaking How to Program series offers unparalleled breadth and depth of object-oriented programming concepts and intermediate-level topics for further study. Their Live Code Approach features thousands of lines of code in hundreds of complete working programs. This enables readers  to confirm that programs run as expected. Java How to Program (Early Objects) 9e contains an optional extensive OOD/UML 2 case study on developing and implementing the software for an automated teller machine.This edition covers both Java SE7 and SE6.

Appendices M, N, O, P, and Q are available at Java How to Program, 9/e's Companion Website (www.pearsonhighered.com/deitel) as PDF documents.

Table of Contents

  1. Java™ How to Program
  2. Deitel® Series Page
  3. Java™ How to Program
  4. Trademarks
  5. Preface
    1. New and Updated Features
    2. Dependency Chart
    3. Teaching Approach
    4. Software Used in Java How to Program, 9/e
    5. Java IDE Resource Kit
    6. Discounts on Deitel Developer Series Books
    7. CourseSmart Web Books
    8. Instructor Supplements
    9. Acknowledgments
    10. About the Authors
    11. Corporate Training from Deitel & Associates, Inc.
  6. Before You Begin
  7. 1 Introduction to Computers and Java
    1. Objectives
    2. Outline
    3. 1.1 Introduction
      1. Java Editions: SE, EE and ME
      2. Computing in Industry and Research
    4. 1.2 Computers: Hardware and Software
      1. Moore’s Law
    5. 1.3 Data Hierarchy
    6. 1.4 Computer Organization
    7. 1.5 Machine Languages, Assembly Languages and High-Level Languages
    8. 1.6 Introduction to Object Technology
      1. The Automobile as an Object
      2. Methods and Classes
      3. Instantiation
      4. Reuse
      5. Messages and Methods Calls
      6. Attributes and Instance Variables
      7. Encapsulation
      8. Inheritance
      9. Object-Oriented Analysis and Design (OOAD)
      10. The UML (Unified Modeling Language)
    9. 1.7 Operating Systems
      1. Windows—A Proprietary Operating System
      2. Linux—An Open-Source Operating System
      3. Android
      4. Android App-Development Chapters on the Companion Website
    10. 1.8 Programming Languages
    11. 1.9 Java and a Typical Java Development Environment
      1. Java Class Libraries
    12. Phase 1: Creating a Program
    13. Phase 2: Compiling a Java Program into Bytecodes
    14. Phase 3: Loading a Program into Memory
    15. Phase 4: Bytecode Verification
    16. Phase 5: Execution
    17. Problems That May Occur at Execution Time
    18. 1.10 Test-Driving a Java Application
    19. 1.11 Web 2.0: Going Social
      1. Google
      2. Web Services and Mashups
      3. Ajax
      4. Social Applications
      5. 1.12 Software Technologies
    20. 1.13 Keeping Up-to-Date with Information Technologies
    21. 1.14 Wrap-Up
    22. Self-Review Exercises
      1. 1.1
      2. 1.2
      3. 1.3
    23. Exercises
    24. Making a Difference
    25. Making a Difference Resources
  8. 2 Introduction to Java Applications
    1. Objectives
    2. Outline
    3. 2.1 Introduction
    4. 2.2 Your First Program in Java: Printing a Line of Text
      1. Commenting Your Programs
      2. Using Blank Lines
      3. Declaring a Class
      4. Class Names and Identifiers
      5. Declaring a Method
      6. Performing Output with System.out.println
      7. Using End-of-Line Comments on Right Braces for Readability
      8. Compiling and Executing Your First Java Application
    5. 2.3 Modifying Your First Java Program
      1. Displaying a Single Line of Text with Multiple Statements
      2. Displaying Multiple Lines of Text with a Single Statement
    6. 2.4 Displaying Text with printf
    7. 2.5 Another Application: Adding Integers
      1. Import Declarations
      2. Declaring Class Addition
      3. Declaring and Creating a Scanner to Obtain User Input from the Keyboard
      4. Declaring Variables to Store Integers
      5. Prompting the User for Input
      6. Obtaining an int as Input from the User
      7. Prompting for and Inputting a Second int
      8. Using Variables in a Calculation
      9. Displaying the Result of the Calculation
      10. Java API Documentation
    8. 2.6 Memory Concepts
    9. 2.7 Arithmetic
      1. Arithmetic Expressions in Straight-Line Form
      2. Parentheses for Grouping Subexpressions
      3. Rules of Operator Precedence
      4. Sample Algebraic and Java Expressions
      5. Evaluation of a Second-Degree Polynomial
    10. 2.8 Decision Making: Equality and Relational Operators
    11. 2.9 Wrap-Up
    12. Summary
      1. Section 2.2 Your First Program in Java: Printing a Line of Text
      2. Section 2.3 Modifying Your First Java Program
      3. Section 2.4 Displaying Text with printf
      4. Section 2.5 Another Application: Adding Integers
      5. Section 2.6 Memory Concepts
      6. Section 2.7 Arithmetic
      7. Section 2.8 Decision Making: Equality and Relational Operators
      8. Self-Review Exercises
        1. 2.1
        2. 2.2
        3. 2.3
        4. 2.4
        5. 2.5
        6. 2.6
    13. Exercises
    14. Making a Difference
  9. 3 Introduction to Classes, Objects, Methods and strings
    1. Objectives
    2. Outline
    3. 3.1 Introduction
    4. 3.2 Declaring a Class with a Method and Instantiating an Object of a Class
      1. Class GradeBook
      2. Class GradeBookTest
      3. Compiling an Application with Multiple Classes
      4. UML Class Diagram for Class GradeBook
    5. 3.3 Declaring a Method with a Parameter
      1. Arguments to a Method
      2. Class Declaration with a Method That Has One Parameter
      3. More on Arguments and Parameters
      4. Updated UML Class Diagram for Class GradeBook
      5. Notes on import Declarations
    6. 3.4 Instance Variables, set Methods and get Methods
      1. GradeBook Class with an Instance Variable, a set Method and a get Method
      2. Access Modifiers public and private
      3. Methods setCourseName and getCourseName
      4. Method displayMessage
      5. GradeBookTest Class That Demonstrates Class GradeBook
      6. set and get Methods
      7. GradeBook UML Class Diagram with an Instance Variable and set and get Methods
    7. 3.5 Primitive Types vs. Reference Types
    8. 3.6 Initializing Objects with Constructors
      1. Adding the Constructor to Class GradeBook’s UML Class Diagram ’s UML Class Diagram
      2. Constructors with Multiple Parameters
    9. 3.7 Floating-Point Numbers and Type double
      1. Floating-Point Number Precision and Memory Requirements
      2. Account Class with an Instance Variable of Type double
      3. AccountTest Class to Use Class Account
      4. UML Class Diagram for Class Account
    10. 3.8 (Optional) GUI and Graphics Case Study: Using Dialog Boxes
      1. Displaying Text in a Dialog Box
      2. Introducing static Methods
      3. Entering Text in a Dialog
      4. GUI and Graphics Case Study Exercise
    11. 3.9 Wrap-Up
    12. Summary
      1. Section 3.2 Declaring a Class with a Method and Instantiating an Object of a Class
      2. Section 3.3 Declaring a Method with a Parameter
      3. Section 3.4 Instance Variables, set Methods and get Methods
      4. Section 3.5 Primitive Types vs. Reference Types
      5. Section 3.6 Initializing Objects with Constructors
      6. Section 3.7 Floating-Point Numbers and Type double
    13. Self-Review Exercises
      1. 3.1
      2. 3.2
      3. 3.3 What is the difference between a local variable and a field?
      4. 3.4 Explain the purpose of a method parameter. What is the difference between a parameter and an argument?
    14. Exercises
    15. Making a Difference
  10. 4 Control Statements: Part 1
    1. Objectives
    2. Outline
    3. 4.1 Introduction
    4. 4.2 Algorithms
    5. 4.3 Pseudocode
    6. 4.4 Control Structures
      1. Sequence Structure in Java
      2. Selection Statements in Java
      3. Repetition Statements in Java
      4. Summary of Control Statements in Java
    7. 4.5 if Single-Selection Statement
    8. 4.6 if……else Double-Selection Statement
      1. Conditional Operator (?:)
      2. Nested if……else Statements
      3. Dangling-else Problem
      4. Blocks
    9. 4.7 while Repetition Statement
    10. 4.8 Formulating Algorithms: Counter-Controlled Repetition
      1. Pseudocode Algorithm with Counter-Controlled Repetition
      2. Implementing Counter-Controlled Repetition in Class GradeBook
      3. Class GradeBookTest
      4. Notes on Integer Division and Truncation
    11. 4.9 Formulating Algorithms: Sentinel-Controlled Repetition
      1. Developing the Pseudocode Algorithm with Top-Down, Stepwise Refinement: The Top and First Refinement
      2. Proceeding to the Second Refinement
      3. Implementing Sentinel-Controlled Repetition in Class GradeBook
      4. Program Logic for Sentinel-Controlled Repetition vs. Counter-Controlled Repetition
      5. Explicitly and Implicitly Converting Between Primitive Types
    12. 4.10 Formulating Algorithms: Nested Control Statements
      1. Complete Second Refinement of Pseudocode and Conversion to Class Analysis
    13. 4.11 Compound Assignment Operators
    14. 4.12 Increment and Decrement Operators
    15. 4.13 Primitive Types
    16. 4.14 (Optional) GUI and Graphics Case Study: Creating Simple Drawings
      1. Java’s Coordinate System
      2. First Drawing Application
      3. Method paintComponent
      4. Class DrawPanelTest
      5. GUI and Graphics Case Study Exercises
    17. 4.15 Wrap-Up
    18. Summary
      1. Section 4.1 Introduction
      2. Section 4.2 Algorithms
      3. Section 4.3 Pseudocode
      4. Section 4.4 Control Structures
      5. Section 4.5 if Single-Selection Statement
      6. Section 4.6 if……else Double-Selection Statement
      7. Section 4.7 while Repetition Statement
      8. Section 4.8 Formulating Algorithms: Counter-Controlled Repetition
      9. Section 4.9 Formulating Algorithms: Sentinel-Controlled Repetition
      10. Section 4.11 Compound Assignment Operators
      11. Section 4.12 Increment and Decrement Operators
      12. Section 4.13 Primitive Types
    19. Self-Review Exercises
      1. 4.1
      2. 4.2
      3. 4.3
      4. 4.4
      5. 4.5
      6. 4.6
      7. 4.7
      8. 4.8
      9. 4.9
    20. Exercises
    21. Making a Difference
  11. 5 Control Statements: Part 2
    1. Objectives
    2. Outline
    3. 5.1 Introduction
    4. 5.2 Essentials of Counter-Controlled Repetition
    5. 5.3 for Repetition Statement
      1. A Closer Look at the for Statement’s Header Statement’s Header
      2. General Format of a for Statement
      3. Representing a for Statement with an Equivalent while statement
      4. Scope of a for Statement’s Control Variable Statement’s Control Variable
      5. Expressions in a for Statement’s Header Are Optional Statement’s Header Are Optional
      6. Placing Arithmetic Expressions in a for Statement’s Header Statement’s Header
      7. Using a for Statement’s Control Variable in the Statements’s Body Statement’s Control Variable in the Statements’s Body
      8. UML Activity Diagram for the for Statement
    6. 5.4 Examples Using the for Statement
      1. Application: Summing the Even Integers from 2 to 20
      2. Application: Compound-Interest Calculations
      3. Formatting strings with Field Widths and Justification
      4. Performing the Interest Calculations
      5. Formatting Floating-Point Numbers
      6. A Warning about Displaying Rounded Values
    7. 5.5 do……while Repetition Statement
    8. 5.6 switch Multiple-Selection Statement
      1. GradeBook Class with switch Statement to Count A, B, C, D and F Grades
      2. Method inputGrades
      3. Method incrementLetterGradeCounter
      4. GradeBookTest Class That Demonstrates Class GradeBook
      5. switch statement UML Activity Diagram
      6. Notes on the Expression in Each case of a switch
      7. Using strings in switch statements (New in Java SE 7)
    9. 5.7 break and continue Statements
      1. break statement
      2. continue Statement
    10. 5.8 Logical Operators
      1. Conditional AND (&&)Operator
      2. Conditional OR (||)Operator
      3. Short-Circuit Evaluation of Complex Conditions
      4. Boolean Logical AND (&&) and Boolean Logical Inclusive OR (| ) Operators
      5. Boolean Logical Exclusive OR (^)
      6. Logical Negation (!)Operator
      7. Logical Operators Example
    11. 5.9 Structured Programming Summary
    12. 5.10 (Optional) GUI and Graphics Case Study: Drawing Rectangles and Ovals
      1. Class ShapesTest
      2. GUI and Graphics Case Study Exercises
    13. 5.11 Wrap-Up
    14. Summary
      1. Section 5.2 Essentials of Counter-Controlled Repetition
      2. Section 5.3 for Repetition Statement
      3. Section 5.4 Examples Using the for Statement
      4. Section 5.5 do……while Repetition Statement
      5. Section 5.6 switch Multiple-Selection Statement
      6. Section 5.7 break and continue Statements
      7. Section 5.8 Logical Operators
    15. Self-Review Exercises
      1. 5.1
      2. 5.2
      3. 5.3
      4. 5.4
    16. Exercises
    17. Making a Difference
  12. 6 Methods: A Deeper Look
    1. Objectives
    2. Outline
    3. 6.1 Introduction
    4. 6.2 Program Modules in Java
    5. 6.3 static Methods, static Fields and Class Math
      1. Math Class Constants PI and E
      2. Why Is Method main Declared static?
    6. 6.4 Declaring Methods with Multiple Parameters
      1. The public and static Keywords
      2. Method maximum
      3. Implementing Method maximum by Reusing Method Math.max
      4. Assembling strings with string Concatenation
    7. 6.5 Notes on Declaring and Using Methods
    8. 6.6 Method-Call Stack and Activation Records
    9. 6.7 Argument Promotion and Casting
    10. 6.8 Java API Packages
    11. 6.9 Case Study: Random-Number Generation
      1. Rolling a Six-Sided Die
      2. Rolling a Six-Sided Die 6,000,000 Times
        1. 6.9.1 Generalized Scaling and Shifting of Random Numbers
        2. 6.9.2 Random-Number Repeatability for Testing and Debugging
    12. 6.10 Case Study: A Game of Chance; Introducing Enumerations
      1. Method rollDice
      2. Method main’s Local Variables
      3. enum Type Status
      4. Logic of the main Method
      5. Why Some Constants Are Not Defined as enum Constants
    13. 6.11 Scope of Declarations
    14. 6.12 Method Overloading
      1. Declaring Overloaded Methods
      2. Distinguishing Between Overloaded Methods
      3. Return Types of Overloaded Methods
    15. 6.13 (Optional) GUI and Graphics Case Study: Colors and Filled Shapes
      1. GUI and Graphics Case Study Exercises
    16. 6.14 Wrap-Up
    17. Summary
      1. Section 6.1 Introduction
      2. Section 6.2 Program Modules in Java
      3. Section 6.3 static Methods, static Fields and Class Math
      4. Section 6.4 Declaring Methods with Multiple Parameters
      5. Section 6.5 Notes on Declaring and Using Methods
      6. Section 6.6 Method-Call Stack and Activation Records
      7. Section 6.7 Argument Promotion and Casting
      8. Section 6.9 Case Study: Random-Number Generation
      9. Section 6.10 Case Study: A Game of Chance; Introducing Enumerations
      10. Section 6.11 Scope of Declarations
      11. Section 6.12 Method Overloading
    18. Self-Review Exercises
      1. 6.1
      2. 6.2
      3. 6.3
      4. 6.4
      5. 6.5
      6. 6.6
    19. Exercises
    20. Making a Difference
  13. 7 Arrays and ArrayLists
    1. Objectives
    2. Outline
    3. 7.1 Introduction
    4. 7.2 Arrays
    5. 7.3 Declaring and Creating Arrays
    6. 7.4 Examples Using Arrays
      1. Creating and Initializing an Array
      2. Using an Array Initializer
      3. Calculating the Values to Store in an Array
      4. Summing the Elements of an Array
      5. Using Bar Charts to Display Array Data Graphically
      6. Using the Elements of an Array as Counters
      7. The frequency Array
      8. Summarizing the Results
      9. Exception Handling: Processing the Incorrect Response
      10. The try Statement
      11. Executing the catch Block
      12. toString Method of the Exception Parameter
    7. 7.5 Case Study: Card Shuffling and Dealing Simulation
      1. Class DeckOfCards
      2. DeckOfCards Constructor
      3. DeckOfCards Method shuffle
      4. DeckOfCards Method dealCard
      5. Shuffling and Dealing Cards
    8. 7.6 Enhanced for Statement
    9. 7.7 Passing Arrays to Methods
      1. Notes on Passing Arguments to Methods
    10. 7.8 Case Study: Class GradeBook Using an Array to Store Grades
      1. Storing Student Grades in an Array in Class GradeBook
      2. Class GradeBookTest That Demonstrates Class GradeBook
    11. 7.9 Multidimensional Arrays
      1. Arrays of One-Dimensional Arrays
      2. Two-Dimensional Arrays with Rows of Different Lengths
      3. Creating Two-Dimensional Arrays with Array-Creation Expressions
      4. Two-Dimensional Array Example: Displaying Element Values
      5. Common Multidimensional-Array Manipulations Performed with for Statements
    12. 7.10 Case Study: Class GradeBook Using a Two-Dimensional Array
      1. Storing Student Grades in a Two-Dimensional Array in Class GradeBook
      2. Methods getMinimum and getMaximum
      3. Method outputBarChart
      4. Method outputGrades
      5. Method getAverage
      6. Class GradeBookTest That Demonstrates Class GradeBook
    13. 7.11 Variable-Length Argument Lists
    14. 7.12 Using Command-Line Arguments
    15. 7.13 Class Arrays
    16. 7.14 Introduction to Collections and Class ArrayList
    17. 7.15 (Optional) GUI and Graphics Case Study: Drawing Arcs
      1. GUI and Graphics Case Study Exercise
    18. 7.16 Wrap-Up
    19. Summary
    20. Section 7.1 Introduction
    21. Section 7.2 Arrays
    22. Section 7.3 Declaring and Creating Arrays
    23. Section 7.4 Examples Using Arrays
    24. Section 7.5 Case Study: Card Shuffling and Dealing Simulation
    25. Section 7.6 Enhanced for Statement
    26. Section 7.7 Passing Arrays to Methods
    27. Section 7.9 Multidimensional Arrays
    28. Section 7.11 Variable-Length Argument Lists
    29. Section 7.12 Using Command-Line Arguments
    30. Section 7.13 Class Arrays
    31. Section 7.14 Introduction to Collections and Class ArrayList
    32. Self-Review Exercises
      1. 7.1
      2. 7.2
      3. 7.3
    33. 7.4
    34. 7.5
    35. Exercises
    36. Exercises 7.30–7.33 are reasonably challenging. Once you’ve done them, you ought to be able to implement most popular card games easily.
    37. Special Section: Building Your Own Computer
    38. Making a Difference
  14. 8 Classes and Objects: A Deeper Look
    1. Objectives
    2. Outline
    3. 8.1 Introduction
    4. 8.2 Time Class Case Study
      1. Time1 Class Declaration
      2. Default Constructor
      3. Method setTime and Throwing Exceptions
      4. Method toUniversalString
      5. Method toString
      6. Using Class Time1
      7. Calling Time1 Method setTime with Invalid Values
      8. Notes on the Time1 Class Declaration
    5. 8.3 Controlling Access to Members
    6. 8.4 Referring to the Current Object’s Members with the this Reference Referring to the Current Object’s Members with the this Reference
    7. 8.5 Time Class Case Study: Overloaded Constructors
      1. Class Time2 with Overloaded Constructors
      2. Class Time2’s Constructors ’s Constructors
      3. Class Time2’s ’s setTime Method
      4. Notes Regarding Class Time2’s set and get Methods and Constructors
      5. Using Class Time2’s Overloaded Constructors ’s Overloaded Constructors
    8. 8.6 Default and No-Argument Constructors
    9. 8.7 Notes on Set and Get Methods
      1. Set and Get Methods vs. public Data
      2. Validity Checking in Set Methods
      3. Predicate Methods
    10. 8.8 Composition
      1. Class Date
      2. Class Employee
      3. Class EmployeeTest
    11. 8.9 Enumerations
    12. 8.10 Garbage Collection and Method finalize
    13. 8.11 static Class Members
    14. Tracking the Number of Employee Objects That Have Been Created
    15. 8.12 static Import
    16. 8.13 final Instance Variables
    17. 8.14 Time Class Case Study: Creating Packages
      1. Steps for Declaring a Reusable Class
      2. Steps 1 and 2: Creating a public Class and Adding the package Statement
      3. Step 3: Compiling the Packaged Class
      4. Step 4: Importing the Reusable Class
      5. Specifying the Classpath During Compilation
      6. Specifying the Classpath When Executing an Application
    18. 8.15 Package Access
    19. 8.16 (Optional) GUI and Graphics Case Study: Using Objects with Graphics
    20. Class MyLine
    21. Class DrawPanel
    22. Class TestDraw
    23. GUI and Graphics Case Study Exercise
    24. 8.17 Wrap-Up
    25. Summary
      1. Section 8.2 Time Class Case Study
      2. Section 8.3 Controlling Access to Members
      3. Section 8.4 Referring to the Current Object’s Members with the Referring to the Current Object’s Members with the this Reference
      4. Section 8.5 Time Class Case Study: Overloaded Constructors
      5. Section 8.6 Default and No-Argument Constructors
      6. Section 8.7 Notes on Set and Get Methods
      7. Section 8.8 Composition
      8. Section 8.9 Enumerations
      9. Section 8.10 Garbage Collection and Method finalize
      10. Section 8.11 static Class Members
      11. Section 8.12 static Import
      12. Section 8.13 final Instance Variables
      13. Section 8.14 Time Class Case Study: Creating Packages
    26. 8.15 Package Access
    27. Self-Review Exercise
      1. 8.1
    28. Exercises
    29. Making a Difference
  15. 9 Object-Oriented Programming: Inheritance
    1. Objectives
    2. Outline
    3. 9.1 Introduction
    4. 9.2 Superclasses and Subclasses
      1. University Community Member Hierarchy
      2. Shape Hierarchy
    5. 9.3 protected Members
    6. 9.4 Relationship between Superclasses and Subclasses
      1. 9.4.1 Creating and Using a CommissionEmployee Class
        1. Overview of Class CommissionEmployee’s Methods and Instance Variables ’s Methods and Instance Variables
          1. Class CommissionEmployee’s Constructor ’s Constructor
          2. Class CommissionEmployee’s earnings Method ’s earnings Method
          3. Class CommissionEmployee’s tostring Method and the @Override Annotation ’s tostring Method and the @Override Annotation
          4. Class CommissionEmployeeTest
      2. 9.4.2 Creating and Using a BasePlusCommissionEmployee Class
        1. Testing Class BasePlusCommissionEmployee
          1. Notes on Class BasePlusCommissionEmployee
      3. 9.4.3 Creating a CommissionEmployee––BasePlusCommissionEmployee Inheritance Hierarchy
        1. A Subclass’s Constructor Must Call Its Superclass’s Constructor
        2. BasePlusCommissionEmployee Method Earnings
      4. 9.4.4 CommissionEmployee––BasePlusCommissionEmployee Inheritance Hierarchy Using protected Instance Variables
        1. Class BasePlusCommissionEmployee
        2. Testing Class BasePlusCommissionEmployee
        3. Notes on Using protected Instance Variables
      5. 9.4.5 CommissionEmployee––BasePlusCommissionEmployee Inheritance Hierarchy Using private Instance Variables
        1. Class BasePlusCommissionEmployee’s earnings Method ’s earnings Method
        2. Class BasePlusCommissionEmployee’s toString Method ’s toString Method
        3. Testing Class BasePlusCommissionEmployee
        4. Summary of the Inheritance Examples in Sections 9.4.1––9.4.5
    7. 9.5 Constructors in Subclasses
    8. 9.6 Software Engineering with Inheritance
    9. 9.7 Class Object
    10. 9.8 (Optional) GUI and Graphics Case Study: Displaying Text and Images Using Labels
      1. GUI and Graphics Case Study Exercise
    11. 9.9 Wrap-Up
    12. Summary
      1. Section 9.1 Introduction
      2. Section 9.2 Superclasses and Subclasses
      3. Section 9.3 protected Members
      4. Section 9.4 Relationship between Superclasses and Subclasses
      5. Section 9.5 Constructors in Subclasses
      6. Section 9.6 Software Engineering with Inheritance
      7. Section 9.7 Object Class
    13. Self-Review Exercises
      1. 9.1
      2. 9.2
    14. Exercises
  16. 10 Object-Oriented Programming: Polymorphism
    1. Objectives
    2. Outline
    3. 10.1 Introduction
      1. Implementing for Extensibility
      2. Chapter Overview
      3. Programming in the Specific
      4. Interfaces
    4. 10.2 Polymorphism Examples
      1. Quadrilaterals
      2. Space Objects in a Video Game
    5. 10.3 Demonstrating Polymorphic Behavior
    6. 10.4 Abstract Classes and Methods
      1. Purpose of Abstract Classes
      2. Declaring an Abstract Class and Abstract Methods
      3. Using Abstract Classes to Declare Variables
      4. Layered Software Systems
    7. 10.5 Case Study: Payroll System Using Polymorphism
      1. 10.5.1 Abstract Superclass Employee
      2. 10.5.2 Concrete Subclass SalariedEmployee
      3. 10.5.3 Concrete Subclass HourlyEmployee
      4. 10.5.4 Concrete Subclass CommissionEmployee
      5. 10.5.5 Indirect Concrete Subclass BasePlusCommissionEmployee
      6. 10.5.6 Polymorphic Processing, Operator instanceof and Downcasting
        1. Creating the Array of Employees
        2. Polymorphically Processing Employees
        3. Performing Type-Specific Operations on BasePlusCommissionEmployees
        4. Calling earnings Polymorphically
        5. Using Reflection to Get Each Employee’s Class Name ’s Class Name
        6. Avoiding Compilation Errors with Downcasting
      7. 10.5.7 Summary of the Allowed Assignments Between Superclass and Subclass Variables
    8. 10.6 final Methods and Classes
      1. Final Methods Cannot Be Overridden
      2. Final Classes Cannot Be Superclasses
    9. 10.7 Case Study: Creating and Using Interfaces
      1. Standardizing Interactions
      2. Software Objects Communicate Via Interfaces
        1. Using an Interface
      3. Relating Disparate Types
      4. Interfaces vs. Abstract Classes
      5. Tagging Interfaces
        1. 10.7.1 Developing a Payable Hierarchy
        2. 10.7.2 Interface Payable
        3. 10.7.3 Class Invoice
        4. 10.7.4 Modifying Class Employee to Implement Interface Payable
        5. 10.7.5 Modifying Class SalariedEmployee for Use in the Payable Hierarchy
        6. 10.7.6 Using Interface Payable to Process Invoices and Employees Polymorphically
        7. 10.7.7 Common Interfaces of the Java API
    10. 10.8 (Optional) GUI and Graphics Case Study: Drawing with Polymorphism
      1. GUI and Graphics Case Study Exercises
    11. 10.9 Wrap-Up
    12. Summary
      1. Section 10.1 Introduction
      2. Section 10.3 Demonstrating Polymorphic Behavior
      3. Section 10.4 Abstract Classes and Methods
      4. Section 10.5 Case Study: Payroll System Using Polymorphism
      5. Section 10.6 final Methods and Classes
      6. Section 10.7 Case Study: Creating and Using Interfaces
    13. Self-Review Exercises
      1. 10.1 Fill in the blanks in each of the following statements:
      2. 10.2 State whether each of the statements that follows is true or false. If false, explain why.
    14. Exercises
    15. Making a Difference
  17. 11 Exception Handling: A Deeper Look
    1. Objectives
    2. Outline
    3. 11.1 Introduction
    4. 11.2 Example: Divide by Zero without Exception Handling
    5. 11.3 Example: Handling ArithmeticExceptions and InputMismatchExceptions
      1. Enclosing Code in a try Block
      2. Catching Exceptions
      3. Termination Model of Exception Handling
      4. Using the throws Clause
    6. 11.4 When to Use Exception Handling
    7. 11.5 Java Exception Hierarchy
      1. Checked vs. Unchecked Exceptions
      2. Catching Subclass Exceptions
      3. Only the First Matching catch Executes
    8. 11.6 finally Block
      1. Throwing Exceptions Using the throw Statement
      2. Rethrowing Exceptions
    9. 11.7 Stack Unwinding and Obtaining Information from an Exception Object
      1. Stack Unwinding
      2. Obtaining Data from an Exception Object
    10. 11.8 Chained Exceptions
    11. 11.9 Declaring New Exception Types
    12. 11.10 Preconditions and Postconditions
    13. 11.11 Assertions
    14. 11.12 (New in Java SE 7) Multi-catch: Handling Multiple Exceptions in One catch
    15. 11.13 (New in Java SE 7) try-with-Resources: Automatic Resource Deallocation
    16. 11.14 Wrap-Up
    17. Summary
      1. Section 11.1 Introduction
      2. Section 11.2 Example: Divide by Zero without Exception Handling
      3. Section 11.3 Example: Handling ArithmeticExceptions and InputMismatchExceptions
      4. Section 11.4 When to Use Exception Handling
      5. Section 11.5 Java Exception Hierarchy
      6. Section 11.6 finally block
      7. Section 11.7 Stack Unwinding and Obtaining Information from an Exception Object
      8. Section 11.8 Chained Exceptions
      9. Section 11.9 Declaring New Exception Types
      10. Section 11.10 Preconditions and Postconditions
      11. Section 11.11 Assertions
      12. Section 11.12 Multi-catch: Handling Multiple Exceptions in One catch
      13. Section 11.13 try-with-Resources: Automatic Resource Deallocation
    18. Self-Review Exercises
    19. Exercises
  18. 12 ATM Case Study, Part 1: Object-Oriented Design with the UML
    1. Objectives
    2. Outline
    3. 12.1 Case Study Introduction
    4. 12.2 Examining the Requirements Document
      1. Requirements Document
      2. Analyzing the ATM System
      3. Use Case Diagrams
      4. Designing the ATM System
      5. Web Resource
    5. Self-Review Exercises for Section 12.2
    6. 12.3 Identifying the Classes in a Requirements Document
      1. Identifying the Classes in a System
      2. Modeling Classes
    7. Self-Review Exercises for Section 12.3
    8. 12.4 Identifying Class Attributes
      1. Identifying Attributes
      2. Modeling Attributes
    9. Self-Review Exercises for Section 12.4
    10. 12.5 Identifying Objects’ States and Activities Identifying Objects’ States and Activities
      1. State Machine Diagrams
      2. Activity Diagrams
    11. Self-Review Exercises for Section 12.5
    12. 12.6 Identifying Class Operations
      1. Modeling Operations
      2. Authenticating a User
      3. Other BankDatabase and Account Operations
      4. Getting the Balances
      5. Crediting and Debiting an Account
      6. Deposit Confirmations Performed by Another Banking System
      7. Displaying Messages
      8. Keyboard Input
      9. Dispensing Cash
      10. Class ATM
      11. Identifying and Modeling Operation Parameters for Class BankDatabase
      12. Identifying and Modeling Operation Parameters for Class Account
      13. Identifying and Modeling Operation Parameters for Class Screen
      14. Identifying and Modeling Operation Parameters for Class CashDispenser
      15. Identifying and Modeling Operation Parameters for Other Classes
    13. Self-Review Exercises for Section 12.6
    14. 12.7 Indicating Collaboration Among Objects
      1. Identifying the Collaborations in a System
      2. Interaction Diagrams
      3. Communication Diagrams
      4. Sequence of Messages in a Communication Diagram
      5. Sequence Diagrams
    15. Self-Review Exercises for Section 12.7
    16. 12.8 Wrap-Up
  19. 13 ATM Case Study Part 2: Implementing an Object-Oriented Design
    1. Objectives
    2. Outline
    3. 13.1 Introduction
    4. 13.2 Starting to Program the Classes of the ATM System
      1. Visibility
      2. Navigability
      3. Implementing the ATM System from Its UML Design
    5. Self-Review Exercises for Section 13.2
    6. 13.3 Incorporating Inheritance and Polymorphism into the ATM System
      1. Generalization
      2. Processing Transactions Polymorphically
      3. Additional Attribute of Classes Withdrawal and Deposit
      4. Class Diagram with Transaction Hierarchy Incorporated
        1. Implementing the ATM System Design (Incorporating Inheritance)
    7. Self-Review Exercises for Section 13.3
    8. 13.4 ATM Case Study Implementation
      1. 13.4.1 Class ATM
        1. ATM Method run
        2. Authenticating a User
        3. Performing Transactions
        4. Creating a Transaction
        5. Exiting the Main Menu and Processing Invalid Selections
        6. Awaiting the Next ATM User
      2. 13.4.2 Class Screen
      3. 13.4.3 Class Keypad
      4. 13.4.4 Class CashDispenser
      5. 13.4.5 Class DepositSlot
      6. 13.4.6 Class Account
      7. 13.4.7 Class BankDatabase
      8. 13.4.8 Class Transaction
      9. 13.4.9 Class BalanceInquiry
      10. 13.4.10 Class Withdrawal
      11. 13.4.11 Class Deposit
      12. 13.4.12 Class ATMCaseStudy
    9. 13.5 Wrap-Up
  20. 14 GUI Components: Part 1
    1. Objectives
    2. Outline
    3. 14.1 Introduction
      1. IDE Support for GUI Design
      2. Sample GUI: The SwingSet3 Demo Application
    4. 14.2 Java’s New Nimbus Look-and-Feel Java’s New Nimbus Look-and-Feel
    5. 14.3 Simple GUI-Based Input/Output with JOptionPane
      1. Input Dialogs
      2. Converting Strings to int Values
      3. Message Dialogs
      4. JOptionPane Message Dialog Constants
    6. 14.4 Overview of Swing Components
      1. Swing vs. AWT
      2. Lightweight vs. Heavyweight GUI Components
      3. Superclasses of Swing’s Lightweight GUI Components
    7. 14.5 Displaying Text and Images in a Window
      1. Labeling GUI Components
      2. Specifying the Layout
      3. Creating and Attaching label1
      4. The Icon Interface and Class ImageIcon
      5. Loading an Image Resource
      6. Creating and Attaching label2
      7. Creating and Attaching label3
      8. Creating and Displaying a LabelFrame Window
    8. 14.6 Text Fields and an Introduction to Event Handling with Nested Classes
      1. Creating the GUI
      2. Steps Required to Set Up Event Handling for a GUI Component
      3. Using a Nested Class to Implement an Event Handler
      4. Inner Class TextFieldHandler
      5. Registering the Event Handler for Each Text Field
      6. Details of Class TextFieldHandler’s ’s actionPerformed Method
      7. Class TextFieldTest
    9. 14.7 Common GUI Event Types and Listener Interfaces
    10. 14.8 How Event Handling Works
      1. Registering Events
      2. Event-Handler Invocation
    11. 14.9 JButton
      1. Accessing the this Reference in an Object of a Top-Level Class From an Inner Class
    12. 14.10 Buttons That Maintain State
      1. 14.10.1 JCheckBox
        1. Relationship Between an Inner Class and Its Top-Level Class
      2. 14.10.2 JRadioButton
    13. 14.11 JComboBox; Using an Anonymous Inner Class for Event Handling
      1. Using an Anonymous Inner Class for Event Handling
    14. 14.12 JList
    15. 14.13 Multiple-Selection Lists
    16. 14.14 Mouse Event Handling
      1. Tracking Mouse Events on a JPanel
    17. 14.15 Adapter Classes
      1. Extending MouseAdapter
    18. 14.16 JPanel Subclass for Drawing with the Mouse
      1. Method paintComponent
      2. Defining the Custom Drawing Area
      3. Using the Custom JPanel in an Application
    19. 14.17 Key Event Handling
    20. 14.18 Introduction to Layout Managers
      1. 14.18.1 FlowLayout
      2. 14.18.2 BorderLayout
      3. 14.18.3 GridLayout
    21. 14.19 Using Panels to Manage More Complex Layouts
    22. 14.20 JTextArea
      1. JScrollPane Scrollbar Policies
    23. 14.21 Wrap-Up
    24. Summary
      1. Section 14.1 Introduction
      2. Section 14.2 Java’s New Nimbus Look-and-Feel Java’s New Nimbus Look-and-Feel
      3. Section 14.3 Simple GUI-Based Input/Output with JOptionPane
      4. Section 14.4 Overview of Swing Components
      5. Section 14.5 Displaying Text and Images in a Window
      6. Section 14.6 Text Fields and an Introduction to Event Handling with Nested Classes
      7. Section 14.7 Common GUI Event Types and Listener Interfaces
      8. Section 14.8 How Event Handling Works
      9. Section 14.9 JButton
      10. Section 14.10 Buttons That Maintain State
      11. Section 14.11 JComboBox and Using an Anonymous Inner Class for Event Handling
      12. Section 14.12 JList
      13. Section 14.13 Multiple-Selection Lists
      14. Section 14.14 Mouse Event Handling
      15. Section 14.15 Adapter Classes
      16. Section 14.16 JPanel Subclass for Drawing with the Mouse
      17. Section 14.17 Key Event Handling
      18. Section 14.18 Introduction to Layout Managers
      19. Section 14.19 Using Panels to Manage More Complex Layouts
      20. Section 14.20 JTextArea
    25. Self-Review Exercises
      1. 14.1
      2. 14.2
      3. 14.3
    26. Exercises
      1. (Optional) GUI and Graphics Case Study Exercise: Expanding the Interface
    27. Making a Difference
  21. 15 Graphics and Java 2D
    1. Objectives
    2. Outline
    3. 15.1 Introduction
    4. 15.2 Graphics Contexts and Graphics Objects
    5. 15.3 Color Control
      1. Drawing in Different Colors
    6. 15.4 Manipulating Fonts
      1. Font Metrics
    7. 15.5 Drawing Lines, Rectangles and Ovals
    8. 15.6 Drawing Arcs
    9. 15.7 Drawing Polygons and Polylines
    10. 15.8 Java 2D API
      1. Lines, Rectangles, Round Rectangles, Arcs and Ellipses
      2. Ovals, Gradient Fills and Paint Objects
      3. Rectangles, Strokes
      4. Rounded Rectangles, BufferedImages and TexturePaint Objects
      5. Arcs
      6. Lines
      7. Creating Your Own Shapes with General Paths
    11. 15.9 Wrap-Up
    12. Summary
      1. Section 15.1 Introduction
      2. Section 15.2 Graphics Contexts and Graphics Objects
      3. Section 15.3 Color Control
      4. Section 15.4 Manipulating Fonts
      5. Section 15.5 Drawing Lines, Rectangles and Ovals
      6. Section 15.6 Drawing Arcs
      7. Section 15.7 Drawing Polygons and Polylines
      8. Section 15.8 Java 2D API
    13. Self-Review Exercises
      1. 15.1
      2. 15.2
      3. 15.3
    14. Exercises
      1. (Optional) GUI and Graphics Case Study: Adding Java 2D
    15. Making a Difference
  22. 16 Strings, Characters and Regular Expressions
    1. Objectives
    2. Outline
    3. 16.1 Introduction
    4. 16.2 Fundamentals of Characters and Strings
      1. 16.3 Class string
      2. 16.3.1 String Constructors
        1. 16.3.2 String Methods length, charAt and getChars
      3. 16.3.3 Comparing Strings
        1. String Method equals
        2. Comparing Strings with the == Operator
          1. String Method equalsIgnoreCase
        3. String Method compareTo
        4. String Method regionMatches
        5. String Methods startsWith and endsWith
      4. 16.3.4 Locating Characters and substrings in strings
      5. 16.3.5 Extracting substrings from strings
      6. 16.3.6 Concatenating strings
      7. 16.3.7 Miscellaneous String Methods
      8. 16.3.8 String Method valueOf
    5. 16.4 Class StringBuilder
      1. 16.4.1 StringBuilder Constructors
      2. 16.4.2 StringBuilder Methods length, capacity, setLength and ensureCapacity
      3. 16.4.3 StringBuilder Methods charAt, setcharAt, getChars and reverse
        1. 16.4.4 StringBuilder append Methods
      4. 16.4.5 StringBuilder Insertion and Deletion Methods
    6. 16.5 Class Character
    7. 16.6 Tokenizing Strings
    8. 16.7 Regular Expressions, Class Pattern and Class Matcher
      1. Quantifiers
      2. Replacing substrings and Splitting strings
      3. Classes Pattern and Matcher
    9. 16.8 Wrap-Up
    10. Summary
      1. Section 16.2 Fundamentals of Characters and strings
      2. Section 16.3 Class String
      3. Section 16.4 Class StringBuilder
      4. Section 16.5 Class Character
      5. Section 16.6 Tokenizing Strings
      6. Section 16.7 Regular Expressions, Class Pattern and Class Matcher
    11. Self-Review Exercises
      1. 16.1
      2. 16.2
    12. Exercises
    13. Special Section: Advanced string-Manipulation Exercises
    14. Special Section: Challenging string-Manipulation Projects
    15. Making a Difference
  23. 17 Files, Streams and Object Serialization
    1. Objectives
    2. Outline
    3. 17.1 Introduction1
    4. 17.2 Files and Streams
      1. Byte-Based and Character-Based Streams
      2. Standard Input, Standard Output and Standard Error Streams
      3. The java.io Package
    5. 17.3 Class File
      1. Creating File Objects
      2. Demonstrating Class File
    6. 17.4 Sequential-Access Text Files
      1. 17.4.1 Creating a Sequential-Access Text File
        1. Class AccountRecord
        2. Class CreateTextFile
        3. Platform-Specific Line-Separator Characters
        4. Class CreateTextFileTest
      2. 17.4.2 Reading Data from a Sequential-Access Text File
      3. 17.4.3 Case Study: A Credit-Inquiry Program
        1. MenuOption Enumeration
        2. CreditInquiry Class
      4. 17.4.4 Updating Sequential-Access Files
    7. 17.5 Object Serialization
      1. Classes ObjectInputStream and ObjectOutputStream
      2. Interfaces ObjectOutput and ObjectInput
      3. 17.5.1 Creating a Sequential-Access File Using Object Serialization
        1. Defining Class AccountRecordSerializable
        2. Writing Serialized Objects to a Sequential-Access File
        3. 17.5.2 Reading and Deserializing Data from a Sequential-Access File
    8. 17.6 Additional java.io Classes
      1. 17.6.1 Interfaces and Classes for Byte-Based Input and Output
        1. Pipe Streams
        2. Filter Streams
        3. Data Streams
        4. Buffered Streams
        5. Memory-Based byte Array Steams
        6. Sequencing Input from Multiple Streams
      2. 17.6.2 Interfaces and Classes for Character-Based Input and Output
        1. Character-Based Buffering Readers and Writers
        2. Memory-Based char Array Readers and Writers
        3. Character-Based File, Pipe and String Readers and Writers
    9. 17.7 Opening Files with JFileChooser
    10. 17.8 Wrap-Up
    11. Summary
      1. Section 17.1 Introduction
      2. Section 17.2 Files and Streams
      3. Section 17.3 Class File
      4. Section 17.4 Sequential-Access Text Files
      5. Section 17.5 Object Serialization
      6. Section 17.6 Additional java.io Classes
      7. Section 17.7 Opening Files with JFileChooser
    12. Self-Review Exercises
      1. 17.1
      2. 17.2
      3. 17.3
      4. 17.4
    13. Exercises
    14. Making a Difference
  24. 18 Recursion
    1. Objectives
    2. Outline
    3. 18.1 Introduction
    4. 18.2 Recursion Concepts
    5. 18.3 Example Using Recursion: Factorials
      1. Reimplementing Class FactorialCalculator Using Class BigInteger
    6. 18.4 Example Using Recursion: Fibonacci Series
      1. Analyzing the Calls to Method Fibonacci
      2. 18.5 Recursion and the Method-Call Stack
    7. 18.6 Recursion vs. Iteration
      1. 18.7 Towers of Hanoi
    8. 18.8 Fractals
      1. The “Lo Fractal”
    9. 18.9 Recursive Backtracking
    10. 18.10 Wrap-Up
    11. Summary
      1. Section 18.1 Introduction
      2. Section 18.2 Recursion Concepts
      3. Section 18.3 Example Using Recursion: Factorials
      4. Section 18.4 Example Using Recursion: Fibonacci Series
      5. Section 18.5 Recursion and the Method-Call Stack
      6. Section 18.6 Recursion vs. Iteration
      7. Section 18.8 Fractals
      8. Section 18.9 Recursive Backtracking
    12. Self-Review Exercises
      1. 18.1
      2. 18.2
      3. 18.3
      4. 18.4
      5. 18.5
      6. 18.6
    13. Exercises
  25. 19 Searching, Sorting and Big O
    1. Objectives
    2. Outline
    3. 19.1 Introduction
    4. 19.2 Searching Algorithms
      1. 19.2.1 Linear Search
        1. Efficiency of Linear Search
        2. O(1) Algorithms
        3. O(n) Algorithms
        4. O(n2) Algorithms
        5. Big O of the Linear Search
        6. 19.2.2 Binary Search
        7. Binary Search Implementation
        8. Efficiency of the Binary Search
    5. 19.3 Sorting Algorithms
      1. 19.3.1 Selection Sort
        1. Efficiency of the Selection Sort
      2. 19.3.2 Insertion Sort
        1. Efficiency of the Insertion Sort
      3. 19.3.3 Merge Sort
        1. Efficiency of the Merge Sort
    6. 19.4 Wrap-Up
    7. Summary
      1. Section 19.1 Introduction
      2. Section 19.2 Searching Algorithms
      3. Section 19.3 Sorting Algorithms
    8. Self-Review Exercises
      1. 19.1
      2. 19.2
      3. 19.3
      4. 19.4
    9. Exercises
  26. 20 Generic Collections
    1. Objectives
    2. Outline
    3. 20.1 Introduction
    4. 20.2 Collections Overview
    5. 20.3 Type-Wrapper Classes for Primitive Types
    6. 20.4 Autoboxing and Auto-Unboxing
    7. 20.5 Interface Collection and Class Collections
    8. 20.6 Lists
      1. 20.6.1 ArrayList and Iterator
        1. New in Java SE 7: Type Inference with the <> Notation
      2. 20.6.2 LinkedList
        1. Method convertToUppercaseStrings
        2. Method removeItems
        3. Method printReversedList
        4. Views into Collections and Arrays Method asList
        5. Viewing Arrays as Lists and Converting Lists to Arrays
    9. 20.7 Collections Methods
      1. 20.7.1 Method sort
        1. Sorting in Ascending Order
        2. Sorting in Descending Order
        3. Sorting with a Comparator
      2. 20.7.2 Method shuffle
      3. 20.7.3 Methods reverse, fill, copy, max and min
      4. 20.7.4 Method binarySearch
      5. 20.7.5 Methods addAll, frequency and disjoint
    10. 20.8 Stack Class of Package java.util
    11. 20.9 Class PriorityQueue and Interface Queue
    12. 20.10 Sets
      1. Sorted Sets
    13. 20.11 Maps
      1. Map Implementation with Hash Tables
    14. 20.12 Properties Class
    15. 20.13 Synchronized Collections
    16. 20.14 Unmodifiable Collections
    17. 20.15 Abstract Implementations
    18. 20.16 Wrap-Up
    19. Summary
      1. Section 20.1 Introduction
      2. Section 20.2 Collections Overview
      3. Section 20.3 Type-Wrapper Classes for Primitive Types
      4. Section 20.4 Autoboxing and Auto-Unboxing
      5. Section 20.5 Interface Collection and Class Collections
      6. Section 20.6 Lists
      7. Section 20.7 Collections Methods
      8. Section 20.8 Stack Class of Package java.util
      9. Section 20.9 Class PriorityQueue and Interface Queue
      10. Section 20.10 Sets
      11. Section 20.11 Maps
      12. Section 20.12 Properties Class
      13. Section 20.13 Synchronized Collections
      14. Section 20.14 Unmodifiable Collections
      15. Section 20.15 Abstract Implementations
    20. Self-Review Exercises
      1. 20.1
      2. 20.2
    21. Execises
  27. 21 Generic Classes and Methods
    1. Objectives
    2. Outline
    3. 21.1 Introduction
    4. 21.2 Motivation for Generic Methods
    5. 21.3 Generic Methods: Implementation and Compile-Time Translation
      1. Erasure at Compilation Time
      2. 21.4 Additional Compile-Time Translation Issues: Methods That Use a Type Parameter as the Return Type
      3. Generic Method maximum
      4. Calling Method maximum
      5. Upper Bound of a Type Parameter
      6. Possible ClassCastExceptions
    6. 21.5 Overloading Generic Methods
    7. 21.6 Generic Classes
      1. Implementing a Generic Stack Class
      2. Testing the Generic Stack Class of Fig. 21.7
      3. Methods testPushDouble and testPopDouble
      4. Methods testPushInteger and testPopInteger
      5. Creating Generic Methods to Test Class Stack&lt;T&gt; <T>
    8. 21.7 Raw Types
      1. Using Raw Types with Generic Class Stack
    9. 21.8 Wildcards in Methods That Accept Type Parameters
      1. Implementing Method sum With a Wildcard Type Argument in Its Parameter
      2. 21.9 Generics and Inheritance: Notes
    10. 21.10 Wrap-Up
    11. Summary
      1. Section 21.1 Introduction
      2. Section 21.2 Motivation for Generic Methods
      3. Section 21.3 Generic Methods: Implementation and Compile-Time Translation
      4. Section 21.4 Additional Compile-Time Translation Issues: Methods That Use a Type Parameter as the Return Type
      5. Section 21.5 Overloading Generic Methods
      6. Section 21.6 Generic Classes
      7. Section 21.7 Raw Types
      8. Section 21.8 Wildcards in Methods That Accept Type Parameters
      9. Section 21.9 Generics and Inheritance: Notes
    12. Self-Review Exercises
      1. 21.1
      2. 21.2
    13. Exercises
  28. 22 Custom Generic Data Structures
    1. Objectives
    2. Outline
    3. 22.1 Introduction
    4. 22.2 Self-Referential Classes
    5. 22.3 Dynamic Memory Allocation
    6. 22.4 Linked Lists
      1. Singly Linked Lists
        1. Implementing a Generic List Class
      2. Generic Classes ListNode and List
      3. Class ListTest
      4. List Method insertAtFront
      5. List Method insertAtBack
      6. List Method removeFromFront
      7. List Method removeFromBack
      8. List Method print
    7. 22.5 Stacks
      1. Stack Class That Inherits from List&lt;T&gt;
      2. Stack Class That Contains a Reference to a List
    8. 22.6 Queues
    9. 22.7 Trees
      1. Overview of Class Tree
      2. Tree Method insertNode
      3. TreeNode Method insert
      4. Tree Methods inorderTraversal, preorderTraversal and postorderTraversal
    10. 22.8 Wrap-Up
    11. Summary
      1. Section 22.1 Introduction
      2. Section 22.2 Self-Referential Classes
      3. Section 22.3 Dynamic Memory Allocation
      4. Section 22.4 Linked Lists
      5. Section 22.5 Stacks
      6. Section 22.6 Queues
      7. Section 22.7 Trees
    12. Self-Review Exercises
      1. 22.1
      2. 22.2
      3. 22.3
      4. 22.4
      5. 22.5
    13. Exercises
    14. Special Section: Building Your Own Compiler
  29. 23 Applets and Java Web Start
    1. Objectives
    2. Outline
    3. 23.1 Introduction
      1. Applet Containers
      2. Java Web Start and the Java Network Launch Protocol (JNLP)
    4. 23.2 Sample Applets Provided with the JDK
      1. Overview of the Demonstration Applets
      2. TicTacToe Applet
      3. DrawTest Applet
      4. Java2D Applet
    5. 23.3 Simple Java Applet: Drawing a String
      1. Creating the Applet Class
      2. Overriding Method paint for Drawing
        1. 23.3.1 Executing WelcomeApplet in the appletviewer
          1. 23.3.2 Executing an Applet in a Web Browser
      3. 23.4 Applet Life-Cycle Methods
      4. 23.5 Initialization with Method init
      5. 23.6 Sandbox Security Model
      6. Preventing Malicious Applets
      7. Digitally Signed Applets
    6. 23.7 Java Web Start and the Java Network Launch Protocol (JNLP)
      1. Java Web Start Features
      2. Java Network Launch Protocol (JNLP)
        1. 23.7.1 Packaging the DrawTest Appletfor UsewithJavaWebStart
        2. 23.7.2 JNLP Document for the DrawTest Applet
          1. Overview of XML
          2. JNLP Document: jnlp Element
          3. JNLP Document: information Element
          4. JNLP Document: resources Element
          5. JNLP Document: applet-desc Element
          6. Launching the Applet with Java Web Start
          7. Viewing the Installed Java Web Start Programs
    7. 23.8 Wrap-Up
    8. Summary
      1. Section 23.1 Introduction
      2. Section 23.2 Sample Applets Provided with the JDK
      3. Section 23.3 Simple Java Applet: Drawing a String
      4. Section 23.4 Applet Life-Cycle Methods
      5. Section 23.5 Initialization with Method init
      6. Section 23.6 Sandbox Security Model
      7. Section 23.7 Java Web Start and the Java Network Launch Protocol (JNLP)
        1. Section 23.7.1 Packaging the DrawTest Applet for Use with Java Web Start
        2. Section 23.7.2 JNLP Document for the DrawTest Applet
    9. Self-Review Exercise
      1. 23.1
    10. Exercises
  30. 24 Multimedia: Applets and Applications
    1. Objectives
    2. Outline
    3. 24.1 Introduction
    4. 24.2 Loading, Displaying and Scaling Images
      1. Configuring the GUI and the JButton&#8217;s Event Handler ’s Event Handler
      2. Opening the Image File Using JNLP’s FileOpenService
      3. Displaying the Image with Class DrawJPanel&#8217;s ’s paintComponent Method
      4. Compiling the Applet
      5. Packaging the Applet for Use with Java Web Start
      6. JNLP Document for LoadImageAndScale Applet
      7. Making the Applet Draggable Outside the Browser Window
    5. 24.3 Animating a Series of Images
      1. Class LogoAnimatorPanel
      2. Method startAnimation
      3. Method paintComponent
      4. Method stopAnimation
        1. Methods getPreferredSize and getMinimumSize
        2. Compiling the Application
      5. Packaging the Application for Use with Java Web Start
      6. JNLP Document for LoadImageAndScale Applet
    6. 24.4 Image Maps
    7. 24.5 Loading and Playing Audio Clips
      1. 24.6 Playing Video and Other Media with Java Media Framework
      2. Creating a Simple Media Player
    8. 24.7 Wrap-Up
    9. 24.8 Web Resources
      1. Java Multimedia API References
    10. Summary
      1. Section 24.2 Loading, Displaying and Scaling Images
      2. Section 24.3 Animating a Series of Images
      3. Section 24.4 Image Maps
      4. Section 24.5 Loading and Playing Audio Clips
      5. Section 24.6 Playing Video and Other Media with Java Media Framework
    11. Self-Review Exercises
      1. 24.1
      2. 24.2
    12. Exercises
    13. Special Section: Challenging Multimedia Projects
    14. Making a Difference
  31. 25 GUI Components: Part 2
    1. Objectives
    2. Outline
    3. 25.1 Introduction
    4. 25.2 JSlider
    5. 25.3 Windows: Additional Notes
    6. 25.4 Using Menus with Frames
      1. Overview of Several Menu-Related Components
      2. Using Menus in an Application
      3. Setting Up the File Menu
        1. Setting Up the Format Menu
      4. Creating the Rest of the GUI and Defining the Event Handlers
    7. 25.5 JPopupMenu
    8. 25.6 Pluggable Look-and-Feel
    9. 25.7 JDesktopPane and JInternalFrame
    10. 25.8 JTabbedPane
    11. 25.9 Layout Managers: BoxLayout and GridBagLayout
      1. BoxLayout Layout Manager
      2. GridBagLayout Layout Manager
      3. GridBagConstraints Constants RELATIVE and REMAINDER
    12. 25.10 Wrap-Up
    13. Summary
      1. Section 25.2 JSlider
      2. Section 25.3 Windows: Additional Notes
      3. Section 25.4 Using Menus with Frames
      4. Section 25.5 JPopupMenu
      5. Section 25.6 Pluggable Look-and-Feel
      6. Section 25.7 JDesktopPane and Jinternal Frame
      7. Section 25.8 JTabbedPane
      8. Section 25.9 Layout Managers: BoxLayout and GridBagLayout
    14. Self-Review Exercises
      1. 25.1
      2. 25.2
      3. 25.3
    15. Exercises
      1. 25.4
      2. 25.5
      3. 25.6
      4. 25.7
      5. 25.8
      6. 25.9
      7. 25.10
      8. 25.11
      9. 25.12
      10. 25.13
      11. 25.14
      12. 25.15
      13. 25.16
  32. 26 Multithreading
    1. Objectives
    2. Outline
    3. 26.1 Introduction
      1. Java Concurrency
        1. Concurrent Programming Uses
      2. Concurrent Programming Is Difficult
      3. Use the Prebuilt Classes of the Concurrency APIs Whenever Possible
    4. 26.2 Thread States: Life Cycle of a Thread
      1. New and Runnable States
      2. Waiting State
      3. Timed Waiting State
      4. Blocked State
      5. Terminated State
      6. Operating-System View of the Runnable State
      7. Thread Priorities and Thread Scheduling
      8. 26.3 Creating and Executing Threads with Executor Framework
      9. Creating Concurrent Tasks with the Runnable Interface
      10. Executing Runnable Objects with an Executor
        1. Using Class Executors to Obtain an ExecutorService
      11. Implementing the Runnable Interface
      12. Using the ExecutorService to Manage Threads that Execute PrintTasks
    5. 26.4 Thread Synchronization
      1. Monitors
        1. 26.4.1 Unsynchronized Data Sharing
      2. Class SimpleArray
      3. Class ArrayWriter
      4. Class SharedArrayTest
        1. 26.4.2 Synchronized Data Sharing&#8212;Making Operations Atomic Synchronized Data Sharing—Making Operations Atomic
        2. Class SimpleArray with Synchronization
      5. 26.5 Producer/Consumer Relationship without Synchronization
      6. Implementing the Producer/Consumer Relationship
    6. 26.6 Producer/Consumer Relationship: ArrayBlockingQueue
    7. 26.7 Producer/Consumer Relationship with Synchronization
      1. Methods wait, notify and notifyAll
      2. Fields and Methods of Class SynchronizedBuffer
      3. Method set and the Producer Thread
      4. Method get and the Consumer Thread
      5. Testing Class SynchronizedBuffer
    8. 26.8 Producer/Consumer Relationship: Bounded Buffers
      1. Bounded Buffers
      2. Bounded Buffers Using ArrayBlockingQueue
      3. Implementing Your Own Bounded Buffer as a Circular Buffer
      4. CircularBuffer Method set
      5. CircularBuffer Method get
      6. CircularBuffer Method displayState
      7. Testing Class CircularBuffer
    9. 26.9 Producer/Consumer Relationship: The Lock and Condition Interfaces
      1. Interface Lock and Class ReentrantLock
        1. Condition Objects and Interface Condition
        2. Lock and Condition vs. the synchronized Keyword
        3. Using Locks and Conditions to Implement Synchronization
    10. 26.10 Concurrent Collections Overview
    11. 26.11 Multithreading with GUI
      1. Class SwingWorker
        1. 26.11.1 Performing Computations in a Worker Thread
      2. Class FibonacciNumbers
        1. 26.11.2 Processing Intermediate Results with SwingWorker
      3. Sieve of Eratosthenes
      4. Method doInBackground
      5. Method process
      6. Method done
      7. Class FindPrimes
    12. 26.12 Interfaces Callable and Future
    13. 26.13 Java SE 7: Fork/Join Framework
    14. 26.14 Wrap-Up
    15. Summary
      1. Section 26.1 Introduction
      2. Section 26.2 Thread States: Life Cycle of a Thread
      3. Section 26.3 Creating and Executing Threads with Executor Framework
      4. Section 26.4 Thread Synchronization
      5. Section 26.5 Producer/Consumer Relationship without Synchronization
      6. Section 26.6 Producer/Consumer Relationship: ArrayBlockingQueue
      7. Section 26.7 Producer/Consumer Relationship with Synchronization
      8. Section 26.8 Producer/Consumer Relationship: Bounded Buffers
      9. Section 26.9 Producer/Consumer Relationship: The Lock and Condition Interfaces
      10. Section 26.11 Multithreading with GUI
      11. Section 26.12 Interfaces Callable and Future
      12. Section 26.13 Java SE 7: Fork/Join Framework
    16. Self-Review Exercises
      1. 26.1
      2. 26.2
    17. Exercises
      1. 26.3
      2. 26.4
      3. 26.5
      4. 25.4
      5. 26.7
      6. 26.8
      7. 26.9
      8. 26.10
      9. 26.11
  33. 27 Networking
    1. Objectives
    2. Outline
    3. 27.1 Introduction
    4. 27.2 Manipulating URLs
      1. Processing Applet Parameters
      2. Storing the Website Names and URLs
      3. Building the Applet’s GUI
      4. Processing a User Selection
      5. Specifying the Target Frame for Method showDocument
      6. 27.3 Reading a File on a Web Server
      7. 27.4 Establishing a Simple Server Using Stream Sockets
      8. Step 1: Create a ServerSocket
        1. Step 2: Wait for a Connection
      9. Step 3: Get the Socket&#8217;s I/O Streams ’s I/O Streams
      10. Step 4: Perform the Processing
      11. Step 5: Close the Connection
      12. 27.5 Establishing a Simple Client Using Stream Sockets
      13. Step 1: Create a Socket to Connect to the sServer
      14. Step 2: Get the Socket&#8217;s I/O Streams ’s I/O Streams
      15. Step 3: Perform the Processing
      16. Step 4: Close the Connection
    5. 27.6 Client/Server Interaction with Stream Socket Connections
      1. Server Class
      2. Method runServer
      3. Method waitForConnection
      4. Method getStreams
        1. Method processConnection
      5. Method closeConnection
      6. Processing User Interactions
      7. Client Class
      8. Method runClient
      9. Method connectToServer
      10. Methods processConnection and closeConnection
      11. Processing User Interactions
    6. 27.7 Datagrams: Connectionless Client/Server Interaction
      1. Server Class
      2. Method waitForPackets
      3. Method displayMessage
      4. Method sendPacketToClient
      5. Client Class
      6. Method waitForPackets
    7. 27.8 Client/Server Tic-Tac-Toe Using a Multithreaded Server
      1. TicTacToeServer Class
      2. TicTacToeClient Class
    8. 27.9 [Web Bonus] Case Study: DeitelMessenger
    9. 27.10 Wrap-Up
    10. Summary
      1. Section 27.1 Introduction
      2. Section 27.2 Manipulating URLs
      3. Section 27.3 Reading a File on a Web Server
      4. Section 27.4 Establishing a Simple Server Using Stream Sockets
      5. Section 27.5 Establishing a Simple Client Using Stream Sockets
      6. Section 27.7 Datagrams: Connectionless Client/Server Interaction
    11. Self-Review Exercises
      1. 27.1
      2. 27.2
    12. Exercises
  34. 28 Accessing Databases with JDBC
    1. Objectives
    2. Outline
    3. 28.1 Introduction1
    4. 28.2 Relational Databases
    5. 28.3 Relational Database Overview: The books Database
      1. Authors Table
      2. AuthorISBN Table
      3. Titles Table
      4. Entity-Relationship (ER) Diagram
    6. 28.4 SQL
      1. 28.4.1 Basic SELECT Query
        1. 28.4.2 WHERE Clause
        2. Pattern Matching: Zero or More Characters
          1. Pattern Matching: Any Character
      2. 28.4.3 ORDER BY Clause
        1. Sorting in Descending Order
        2. Sorting By Multiple Columns
        3. Combining the WHERE and ORDER BY Clauses
      3. 28.4.4 Merging Data from Multiple Tables: INNER JOIN
        1. 28.4.5 INSERT Statement
        2. 28.4.6 UPDATE Statement
      4. 28.4.7 DELETE Statement
    7. 28.5 Instructions for Installing MySQL and MySQL Connector/J
      1. Installing MySQL
      2. Installing MySQL Connector/J
    8. 28.6 Instructions for Setting Up a MySQL User Account
    9. 28.7 Creating Database books in MySQL
    10. 28.8 Manipulating Databases with JDBC
      1. 28.8.1 Connecting to and Querying a Database
        1. Connecting to the Database
          1. Creating a Statement for Executing Queries
        2. Executing a Query
        3. Processing a Query’s ResultSet
          1. Java SE 7: Automatically Closing Connections, Statements and ResultSets
      2. 28.8.2 Querying the books Database
        1. ResultSetTableModel Class
        2. ResultSetTableModel Constructor
        3. ResultSetTableModel Method getColumnClass
        4. ResultSetTableModel Method getColumnCount
        5. ResultSetTableModel Method getColumnName
        6. ResultSetTableModel Method getRowCount
        7. ResultSetTableModel Method getValueAt
        8. ResultSetTableModel Method setQuery
        9. ResultSetTableModel Method disconnectFromDatabase
        10. DisplayQueryResults Class
        11. Sorting Rows in a JTable
        12. Filtering Rows in a JTable
    11. 28.9 RowSet Interface
      1. Connected and Disconnected RowSets
        1. Using a RowSet
    12. 28.10 Java DB/Apache Derby
    13. 28.11 PreparedStatements
      1. Address Book Application that Uses PreparedStatements
      2. Class Person
      3. Class PersonQueries
      4. Creating PreparedStatements
      5. PersonQueries Method getAllPeople
      6. PersonQueries Methods addPerson and Close
      7. Class AddressBookDisplay
    14. 28.12 Stored Procedures
      1. 28.13 Transaction Processing
    15. 28.14 Wrap-Up
    16. 28.15 Web Resources
    17. Summary
      1. Section 28.1 Introduction
      2. Section 28.2 Relational Databases
      3. Section 28.4.1 Basic SELECT Query
      4. Section 28.4.2 WHERE Clause
      5. Section 28.4.3 ORDER BY Clause
      6. Section 28.4.4 Merging Data from Multiple Tables: INNER JOIN
      7. Section 28.4.5 INSERT Statement
      8. Section 28.4.6 UPDATE Statement
      9. Section 28.4.7 DELETE Statement
      10. Section 28.8.1 Connecting to and Querying a Database
      11. Section 28.8.2 Querying the books Database
      12. Section 28.9 RowSet Interface
      13. Section 28.10 Java DB/Apache Derby
      14. Section 28.11 PreparedStatements
      15. Section 28.12 Stored Procedures
      16. Section 28.13 Transaction Processing
    18. Self-Review Exercise
      1. 28.1
    19. Exercises
  35. 29 JavaServer&#8482; Faces Web Apps: Part 1 JavaServer™ Faces Web Apps: Part 1
    1. Objectives
      1. Outline
    2. 29.1 Introduction
      1. Required Software for This Chapter
    3. 29.2 HyperText Transfer Protocol (HTTP) Transactions
      1. XHTML Documents
      2. URLs
      3. Parts of a URL
      4. Making a Request and Receiving a Response
      5. HTTP Headers
      6. HTTP GET and POST Requests
        1. Client-Side Caching
    4. 29.3 Multitier Application Architecture
    5. 29.4 Your First JSF Web App
      1. Executing the WebTime App
        1. 29.4.1 The Default index.xhtml Document: Introducing Facelets
      2. Facelets: XHTML and JSF Markup
      3. XML Declaration, Comments and the DOCTYPE Declaration
      4. Specifying the XML Namespaces Used in the Document
      5. The h:head and h:body Elements
        1. 29.4.2 Examining the WebTimeBean Class
      6. JavaBeans
      7. Class WebTimeBean
      8. The @ManagedBean Annotation
      9. Processing the EL Expression
        1. 29.4.3 Building the WebTime JSF Web App in NetBeans
      10. Creating the JSF Web Application Project
      11. Examining the NetBeans Projects Window
      12. Examining the Default index.xhtml Page
      13. Editing the h:head Element&#8217;s Contents Element’s Contents
      14. Editing the h:body Element&#8217;s Contents Element’s Contents
      15. Defining the Page’s Logic: Class WebTimeBean
      16. Adding the EL Expression to the index.xhtml Page
      17. Running the Application
      18. Debugging the Application
      19. Testing the Application from Other Web Browsers
    6. 29.5 Model-View-Controller Architecture of JSF Apps
    7. 29.6 Common JSF Components
      1. h:panelGrid Element
      2. h:graphicImage Element and Resource Libraries
      3. h:inputText Element
      4. h:selectOneMenu Element
      5. h:outputLink Element
      6. h:selectOneMenu Element
      7. h:commandButton Element
    8. 29.7 Validation Using JSF Standard Validators
      1. Validating Form Data in a Web Application
      2. Class ValidationBean
      3. index.xhtml
      4. First Row of the h:panelGrid
      5. Validating the nameInputText Element&#8217;s Contents Element’s Contents
      6. Second and Third Rows of the h:panelGrid
      7. Validating the e-Mail Address
      8. Validating the Phone Number
      9. Submitting the Form—More Details of the JSF Lifecycle
    9. 29.8 Session Tracking
      1. Personalization
      2. Privacy
      3. Recognizing Clients
        1. 29.8.1 Cookies
          1. 29.8.2 Session Tracking with @SessionScoped Beans
        2. Test-Driving the App
      4. @SessionScoped Class SelectionsBean
      5. Methods of Class SelectionsBean
      6. index.xhtml
      7. recommendations.xhtml
      8. Iterating Through the List of Books
    10. 29.9 Wrap-Up
    11. Summary
      1. Section 29.1 Introduction
      2. Section 29.2 HyperText Transfer Protocol (HTTP) Transactions
      3. Section 29.3 Multitier Application Architecture
      4. Section 29.4 Your First JSF Web App
        1. Section 29.4.1 The Default index.xhtml Document: Introducing Facelets
        2. Section 29.4.2 Examining the WebTimeBean Class
      5. Section 29.5 Model-View-Controller Architecture of JSF Apps
      6. Section 29.6 Common JSF Components
      7. Section 29.7 Validation Using JSF Standard Validators
      8. Section 29.8 Session Tracking
        1. Section 29.8.1 Cookies
        2. Section 29.8.2 Session Tracking with @SessionScoped Beans
    12. Self-Review Exercises
      1. 29.1
      2. 29.2
    13. Exercises
  36. 30 JavaServer&#8482; Faces Web Apps: Part 2 JavaServer™ Faces Web Apps: Part 2
    1. Objectives
    2. Outline
    3. 30.1 Introduction
    4. 30.2 Accessing Databases in Web Apps
      1. 30.2.1 Setting Up the Database
        1. Open NetBeans and Ensure that Java DB and GlassFish Are Running
        2. Creating a Connection Pool
        3. Creating a Data Source Name
        4. Populate the addressbook Database with Sample Data
      2. 30.2.2 @ManagedBean Class AddressBean
        1. Injecting the DataSource into Class AddressBean
        2. AddressBean Method getAddresses
        3. AddressBean Method save
      3. 30.2.3 index.xhtml Facelets Page
        1. The h:dataTable Element
        2. The h:column Elements
      4. 30.2.4 addentry.xhtml Facelets Page
    5. 30.3 Ajax
      1. Traditional Web Applications
      2. Ajax Web Applications
    6. 30.4 Adding Ajax Functionality to the Validation App
      1. index.xhtml
      2. Adding id Attributesto Elements
      3. f:ajax Element
    7. 30.5 Wrap-Up
    8. Summary
      1. Section 30.2.1 Setting Up the Database
      2. Section 30.2.2 @ManagedBean Class AddressBean
      3. Section 30.2.3 index.xhtml Facelets Page
      4. Section 30.2.4 addentry.xhtml Facelets Page
      5. Section 30.3 Ajax
      6. Section 30.4 Adding Ajax Functionality to the Validation App
    9. Self-Review Exercise
      1. 30.1
    10. Exercises
  37. 31 Web Services
    1. Objectives
    2. Outline
    3. 31.1 Introduction
      1. Business-to-Business Transactions
      2. NetBeans
    4. 31.2 Web Service Basics
    5. 31.3 Simple Object Access Protocol (SOAP)
    6. 31.4 Representational State Transfer (REST)
    7. 31.5 JavaScript Object Notation (JSON)
    8. 31.6 Publishing and Consuming SOAP-Based Web Services
      1. 31.6.1 Creating a Web Application Project and Adding a Web Service Class in NetBeans
        1. Creating a Web Application Project in NetBeans
        2. Adding a Web Service Class to a Web Application Project
      2. 31.6.2 Defining the WelcomeSOAP Web Service in NetBeans
        1. Annotation import Declarations
        2. @WebService Annotation
        3. WelcomeSOAP Service’s welcome Method
        4. Completing the Web Service’s Code
      3. 31.6.3 Publishing the WelcomeSOAP Web Service from NetBeans
      4. 31.6.4 Testing the WelcomeSOAP Web Service with GlassFish Application Server&#8217;s Tester Web Page Testing the WelcomeSOAP Web Service with GlassFish Application Server’s Tester Web Page
        1. Application Server Note
        2. Testing the WelcomeSOAP Web Service from Another Computer
      5. 31.6.5 Describing a Web Service with the Web Service Description Language (WSDL)
        1. Accessing the WelcomeSOAP Web Service’s WSDL from Another Computer
      6. 31.6.6 Creating a Client to Consume the WelcomeSOAP Web Service
        1. Service Endpoint Interface (SEI)
        2. Creating a Desktop Application Project in NetBeans
        3. Step 2: Adding a Web Service Reference to an Application
      7. 31.6.7 Consuming the WelcomeSOAP Web Service
    9. 31.7 Publishing and Consuming REST-Based XML Web Services
      1. 31.7.1 Creating a REST-Based XML Web Service
        1. Testing RESTful Web Services
      2. 31.7.2 Consuming a REST-Based XML Web Service
    10. 31.8 Publishing and Consuming REST-Based JSON Web Services
      1. 31.8.1 Creating a REST-Based JSON Web Service
      2. 31.8.2 Consuming a REST-Based JSON Web Service
    11. 31.9 Session Tracking in a SOAP Web Service
      1. 31.9.1 Creating a Blackjack Web Service
        1. Session Tracking in Web Services: @HttpSessionScope Annotation
        2. Client Interactions with the Blackjack Web Service
      2. 31.9.2 Consuming the Blackjack Web Service
        1. Configuring the Client for Session Tracking
        2. Method gameOver
        3. Method dealJButtonActionPerformed
        4. Method hitJButtonActionPerformed
        5. Method dealerPlay
        6. Method standJButtonActionPerformed
        7. Method displayCard
    12. 31.10 Consuming a Database-Driven SOAP Web Service
      1. 31.10.1 Creating the Reservation Database
        1. Creating the Reservation Web Service
      2. 31.10.2 Creating a Web Application to Interact with the Reservation Service
        1. index.xhtml
        2. ReservationBean.java
    13. 31.11 Equation Generator: Returning User-Defined Types
      1. Defining Class Equation
        1. 31.11.1 Creating the EquationGeneratorXML Web Service
        2. 31.11.2 Consuming the EquationGeneratorXML Web Service
        3. 31.11.3 Creating the EquationGeneratorJSON Web Service
        4. 31.11.4 Consuming the EquationGeneratorJSON Web Service
    14. 31.12 Wrap-Up
    15. Summary
      1. Section 31.1 Introduction
      2. Section 31.2 Web Service Basics
      3. Section 31.3 Simple Object Access Protocol (SOAP)
      4. Section 31.4 Representational State Transfer (REST)
      5. Section 31.5 JavaScript Object Notation (JSON)
        1. Section 31.6.1 Creating a Web Application Project and Adding a Web Service Class in NetBeans
        2. Section 31.6.2 Defining the WelcomeSOAP Web Service in NetBeans
        3. Section 31.6.3 Publishing the WelcomeSOAP Web Service from NetBeans
        4. Section 31.6.4 Testing the WelcomeSOAP Web Service with GlassFish Application Server&#8217;s Tester Web Page Testing the WelcomeSOAP Web Service with GlassFish Application Server’s Tester Web Page
        5. Section 31.6.5 Describing a Web Service with the Web Service Description Language (WSDL)
        6. Section 31.6.6 Creating a Client to Consume the WelcomeSOAP Web Service
        7. Section 31.6.7 Consuming the WelcomeSOAP Web Service
        8. Section 31.7.1 Creating a REST-Based XML Web Service
        9. Section 31.7.2 Consuming a REST-Based XML Web Service
      6. Section 31.8 Publishing and Consuming REST-Based JSON Web Services
        1. Section 31.8.1 Creating a REST-Based JSON Web Service
        2. Section 31.8.2 Consuming a REST-Based JSON Web Service
      7. Section 31.9 Session Tracking in a SOAP Web Service
        1. Section 31.9.1 Creating a Blackjack Web Service
        2. Section 31.9.2 Consuming the Blackjack Web Service
      8. Section 31.11 Equation Generator: Returning User-Defined Types
    16. Self-Review Exercises
      1. 31.1
      2. 31.2
    17. Exercises
    18. Making a Difference
  38. A Operator Precedence Chart
  39. B ASCII Character Set
  40. C Keywords and Reserved Words
  41. D Primitive Types
  42. E Using the Java API Documentation
    1. E.1 Introduction
    2. E.2 Navigating the Java API
      1. Frames in the API Documentation’s index.html Page
      2. Important Links in the index.html Page
      3. Viewing the Index Page
      4. Viewing a Specific Package
      5. Viewing the Details of a Class
      6. Summary Sections in a Class’s Documentation Page
      7. Detail Sections in a Class’s Documentation Page
  43. F Using the Debugger
    1. Objectives
    2. Outline
    3. F.1 Introduction
    4. F.2 Breakpoints and the run, stop, cont and print Commands
    5. F.3 The print and set Commands
    6. F.4 Controlling Execution Using the step, step up and next Commands
    7. F.5 The watch Command
    8. F.6 The clear Command
    9. F.7 Wrap-Up
    10. Self-Review Exercises
  44. G Formatted Output
    1. Objectives
    2. Outline
    3. G.1 Introduction
    4. G.2 Streams
    5. G.3 Formatting Output with printf
    6. G.4 Printing Integers
    7. G.5 Printing Floating-Point Numbers
    8. G.6 Printing Strings and Characters
      1. G.7 Printing Dates and Times
    9. G.8 Other Conversion Characters
      1. G.9 Printing with Field Widths and Precisions
    10. G.10 Using Flags in the printf Format String
    11. G.11 Printing with Argument Indices
    12. G.12 Printing Literals and Escape Sequences
      1. G.13 Formatting Output with Class Formatter
    13. G.14 Wrap-Up
    14. Summary
      1. Section G.2 Streams
      2. Section G.3 Formatting Output with printf
      3. Section G.4 Printing Integers
      4. Section G.5 Printing Floating-Point Numbers
      5. Section G.6 Printing Strings and Characters
      6. Section G.7 Printing Dates and Times
      7. Section G.8 Other Conversion Characters
      8. Section G.9 Printing with Field Widths and Precisions
      9. Section G.10 Using Flags in the printf Format String
      10. Section G.11 Printing with Argument Indices
      11. Section G.13 Formatting Output with Class Formatter
    15. Self-Review Exercises
      1. G.1
      2. G.2
      3. G.3
    16. Exercises
      1. G.4
      2. G.5
      3. G.6
      4. G.7
      5. G.8
      6. G.9
      7. G.10
      8. G.11
      9. G.12
      10. G.13
  45. H Number Systems
    1. Objectives
      1. Outline
    2. H.1 Introduction
    3. H.2 Abbreviating Binary Numbers as Octal and Hexadecimal Numbers
    4. H.3 Converting Octal and Hexadecimal Numbers to Binary Numbers
    5. H.4 Converting from Binary, Octal or Hexadecimal to Decimal
    6. H.5 Converting from Decimal to Binary, Octal or Hexadecimal
    7. H.6 Negative Binary Numbers: Two&#8217;s Complement Notation Negative Binary Numbers: Two’s Complement Notation
    8. Summary
    9. Self-Review Exercises
    10. Exercises
  46. I GroupLayout
    1. I.1 Introduction
    2. I.2 GroupLayout Basics
      1. Sequential and Parallel Arrangements
      2. Groups and Alignment
      3. Spacing
      4. Sizing Components
    3. I.3 Building a ColorChooser
      1. Creating a New Project
      2. Adding a New Subclass of JFrame to the Project
      3. Build the GUI
      4. Editing the Source Code and Adding Event Handlers
    4. I.4 GroupLayout Web Resources
  47. J Java Desktop Integration Components
    1. J.1 Introduction
    2. J.2 Splash Screens
    3. J.3 Desktop Class
    4. J.4 Tray Icons
  48. K Mashups
    1. K.1 Introduction
    2. K.2 Popular Mashups
    3. K.3 APIs Commonly Used in Mashups
    4. K.4 Deitel Mashups Resource Center
    5. K.5 Deitel RSS Resource Center
    6. K.6 Mashup Performance and Reliability Issues
  49. L Unicode®
    1. L.1 Introduction
    2. L.2 Unicode Transformation Formats
    3. L.3 Characters and Glyphs
    4. L.4 Advantages/Disadvantages of Unicode
    5. L.5 Using Unicode
    6. L.6 Character Ranges
  50. Appendices on the Web
  51. Index
    1. Symbols
    2. Numerics
    3. A
    4. B
    5. C
    6. D
    7. E
    8. F
    9. G
    10. H
    11. I
    12. J
    13. K
    14. L
    15. M
    16. N
    17. O
    18. P
    19. Q
    20. R
    21. S
    22. T
    23. U
    24. V
    25. W
    26. X
    27. Y
    28. Z