Java How to Program, Early Objects, 11th Edition

Book description

For courses in Java programming

Unparalleled breadth and depth of object-oriented programming concepts

The Deitels’ groundbreaking How to Program series offers unparalleled breadth and depth of programming fundamentals, object-oriented programming concepts and intermediate-level topics for further study. Java How to Program, Early Objects, 11th Edition, presents leading-edge computing technologies using the Deitel signature live-code approach, which demonstrates concepts in hundreds of complete working programs. The 11th Edition presents updated coverage of Java SE 8 and new Java SE 9 capabilities, including JShell, the Java Module System, and other key Java 9 topics. [Java How to Program, Late Objects, 11th Edition also is available.]

Also Available with MyLab Programming.

MyLab™ Programmingis an online learning system designed to engage students and improve results. MyLab Programmingconsists of a set of programming exercises correlated to the programming concepts in this book. Through hundreds of practice problems, the system automatically detects errors in the logic and syntax of their code submissions and offers targeted hints that enable students to figure out what went wrong—and why. MyLab Programmingimproves the programming competence of beginning students who often struggle with the basic concepts and paradigms of popular high-level programming languages. For instructors, a comprehensive gradebook tracks correct and incorrect answers and stores the code inputted by students for review.

Note: You are purchasing a standalone product; MyLab™ & Mastering™ does not come packaged with this content. Students, if interested in purchasing this title with MyLab & Mastering, ask your instructor for the correct package ISBN and Course ID. Instructors, contact your Pearson representative for more information.

If you would like to purchase both the physical text and MyLab & Mastering, search for:

0134800273 / 9780134800271 Java How to Program, Early Objects Plus MyLab Programming with Pearson eText -- Access Card Package, 11/e

Package consists of:

  • 0134743350 / 9780134743356 Java How to Program, Early Objects

  • 0134752120 / 9780134752129 MyLab Programming with Pearson eText -- Access Code Card -- for Java How to Program, Early Objects

Students can use the URL and phone number below to help answer their questions:

http://247pearsoned.custhelp.com/app/home

800-677-6337

Table of contents

  1. Java™ How to Program Early Objects
  2. How To Program Series
  3. Deitel® Developer Series
  4. Simply Series
  5. VitalSource Web Books
  6. LiveLessons Video Learning Products
  7. REVEL™ Interactive Multimedia
  8. Java™ How to Program Early Objects
  9. Trademarks
  10. Contents
  11. Foreword
  12. Preface
    1. New and Updated Features
    2. Flexibility Using Java SE 8 or the New Java SE 9
    3. Java How to Program, 11/e’s Modular Organization1
    4. Introduction and Programming Fundamentals (Parts 1 and 2)
    5. Flexible Coverage of Java 9: JShell, the Module System and Other Java 9 Topics (JShell Begins in Part 1; the Rest is in Part 9)
    6. Object-Oriented Programming (Part 3)
    7. Flexible JavaFX GUI, Graphics and Multimedia Coverage (Part 4) and Optional Swing Coverage (Part 11)
    8. Data Structures and Generic Collections (Part 5)
    9. Flexible Lambdas and Streams Coverage (Chapter 17)
    10. Database: JDBC and JPA (Part 7)
    11. Web Application Development and Web Services (Part 8)
    12. Optional Online Object-Oriented Design Case Study (Part 10)
    13. Teaching Approach
    14. Programming Wisdom
    15. What are JEPs, JSRs and the JCP?
    16. Secure Java Programming
    17. Companion Website: Source Code, VideoNotes, Online Chapters and Online Appendices
    18. Software Used in Java How to Program, 11/e
    19. Java Documentation Links
    20. Java How to Program, Late Objects Version, 11/e
    21. Instructor Supplements
    22. Online Practice and Assessment with MyProgrammingLab™
    23. Keeping in Touch with the Authors
    24. Reviewers
    25. A Special Thank You to Robert Field
    26. A Special Thank You to Brian Goetz
    27. About the Authors
    28. About Deitel® & Associates, Inc. & Associates, Inc.
    29. About the Cover Art
  13. Before You Begin
  14. 1 Introduction to Computers, the Internet and Java
    1. Objectives
    2. Outline
    3. 1.1 Introduction
    4. 1.2 Hardware and Software
      1. 1.2.1 Moore’s Law
      2. 1.2.2 Computer Organization
    5. 1.3 Data Hierarchy
    6. 1.4 Machine Languages, Assembly Languages and High-Level Languages
    7. 1.5 Introduction to Object Technology
      1. 1.5.1 Automobile as an Object
      2. 1.5.2 Methods and Classes
      3. 1.5.3 Instantiation
      4. 1.5.4 Reuse
      5. 1.5.5 Messages and Method Calls
      6. 1.5.6 Attributes and Instance Variables
      7. 1.5.7 Encapsulation and Information Hiding
      8. 1.5.8 Inheritance
      9. 1.5.9 Interfaces
      10. 1.5.10 Object-Oriented Analysis and Design (OOAD)
      11. 1.5.11 The UML (Unified Modeling Language)
    8. 1.6 Operating Systems
      1. 1.6.1 Windows—A Proprietary Operating System
      2. 1.6.2 Linux—An Open-Source Operating System
      3. 1.6.3 Apple’s macOS and Apple’s iOS for iPhone®, iPad® and iPod Touch® Devices
      4. 1.6.4 Google’s Android
    9. 1.7 Programming Languages
    10. 1.8 Java
    11. 1.9 A Typical Java Development Environment
    12. 1.10 Test-Driving a Java Application
    13. 1.11 Internet and World Wide Web
      1. 1.11.1 Internet: A Network of Networks
      2. 1.11.2 World Wide Web: Making the Internet User-Friendly
      3. 1.11.3 Web Services and Mashups
      4. 1.11.4 Internet of Things
    14. 1.12 Software Technologies
    15. 1.13 Getting Your Questions Answered
    16. Self-Review Exercises
    17. Answers to Self-Review Exercises
    18. Exercises
    19. Making a Difference
  15. 2 Introduction to Java Applications; Input/Output and Operators
    1. Objectives
    2. Outline
    3. 2.1 Introduction
    4. 2.2 Your First Program in Java: Printing a Line of Text
      1. 2.2.1 Compiling the Application
      2. 2.2.2 Executing the Application
    5. 2.3 Modifying Your First Java Program
    6. 2.4 Displaying Text with printf
    7. 2.5 Another Application: Adding Integers
      1. 2.5.1 import Declarations
      2. 2.5.2 Declaring and Creating a Scanner to Obtain User Input from the Keyboard
      3. 2.5.3 Prompting the User for Input
      4. 2.5.4 Declaring a Variable to Store an Integer and Obtaining an Integer from the Keyboard
      5. 2.5.5 Obtaining a Second Integer
      6. 2.5.6 Using Variables in a Calculation
      7. 2.5.7 Displaying the Calculation Result
      8. 2.5.8 Java API Documentation
      9. 2.5.9 Declaring and Initializing Variables in Separate Statements
    8. 2.6 Memory Concepts
    9. 2.7 Arithmetic
    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.2.1 Compiling the Application
      3. Section 2.2.2 Executing the Application
      4. Section 2.3 Modifying Your First Java Program
      5. Section 2.4 Displaying Text with printf
      6. Section 2.5.1 import Declarations
      7. Section 2.5.2 Declaring and Creating a Scanner to Obtain User Input from the Keyboard
      8. Section 2.5.3 Prompting the User for Input
      9. Section 2.5.4 Declaring a Variable to Store an Integer and Obtaining an Integer from the Keyboard
      10. Section 2.5.6 Using Variables in a Calculation
      11. Section 2.5.7 Displaying the Calculation Result
      12. Section 2.5.9 Declaring and Initializing Variables in Separate Statements
      13. Section 2.6 Memory Concepts
      14. Section 2.7 Arithmetic
      15. Section 2.8 Decision Making: Equality and Relational Operators
    13. Self-Review Exercises
    14. Answers to Self-Review Exercises
    15. Exercises
    16. Making a Difference
  16. 3 Introduction to Classes, Objects, Methods and Strings
    1. Objectives
    2. Outline
    3. 3.1 Introduction1
    4. 3.2 Instance Variables, set Methods and get Methods
      1. 3.2.1 Account Class with an Instance Variable, and set and get Methods
        1. Class Declaration
        2. Identifiers and Camel-Case Naming
        3. Instance Variable name
        4. Access Modifiers public and private
        5. setName Method of Class Account
        6. Parameters Are Local Variables
        7. setName Method Body
        8. getName Method of Class Account
      2. 3.2.2 AccountTest Class That Creates and Uses an Object of Class Account
        1. Driver Class AccountTest
        2. Scanner Object for Receiving Input from the User
        3. Instantiating an Object—Keyword new and Constructors
        4. Calling Class Account’s getName Method
        5. null—the Default Initial Value for String Variables
        6. Calling Class Account’s setName Method
        7. Displaying the Name That Was Entered by the User
      3. 3.2.3 Compiling and Executing an App with Multiple Classes
      4. 3.2.4 Account UML Class Diagram
        1. Top Compartment
        2. Middle Compartment
        3. Bottom Compartment
        4. Return Types
        5. Parameters
      5. 3.2.5 Additional Notes on Class AccountTest
        1. static Method main
        2. Notes on import Declarations
      6. 3.2.6 Software Engineering with private Instance Variables and public set and get Methods
        1. Conceptual View of an Account Object with Encapsulated Data
    5. 3.3 Account Class: Initializing Objects with Constructors
      1. 3.3.1 Declaring an Account Constructor for Custom Object Initialization
        1. Account Constructor Declaration
        2. Parameter name of Class Account’s Constructor and Method setName
      2. 3.3.2 Class AccountTest: Initializing Account Objects When They’re Created
        1. Constructors Cannot Return Values
        2. Default Constructor
        3. There’s No Default Constructor in a Class That Declares a Constructor
        4. Adding the Constructor to Class Account’s UML Class Diagram
    6. 3.4 Account Class with a Balance; Floating-Point Numbers
      1. 3.4.1 Account Class with a balance Instance Variable of Type double
        1. Account Class Two-Parameter Constructor
        2. Account Class deposit Method
        3. Account Class getBalance Method
        4. Account’s Methods Can All Use balance
      2. 3.4.2 AccountTest Class to Use Class Account
        1. Displaying the Account Objects’ Initial Balances
        2. Formatting Floating-Point Numbers for Display
        3. Reading a Floating-Point Value from the User and Making a Deposit
        4. Duplicated Code in Method main
        5. UML Class Diagram for Class Account
    7. 3.5 Primitive Types vs. Reference Types
    8. 3.6 (Optional) GUI and Graphics Case Study: A Simple GUI
      1. 3.6.1 What Is a Graphical User Interface?
      2. 3.6.2 JavaFX Scene Builder and FXML
        1. FXML (FX Markup Language)
      3. 3.6.3 Welcome App—Displaying Text and an Image
      4. 3.6.4 Opening Scene Builder and Creating the File Welcome.fxml
      5. 3.6.5 Adding an Image to the Folder Containing Welcome.fxml
      6. 3.6.6 Creating a VBox Layout Container
      7. 3.6.7 Configuring the VBox
        1. Specifying the VBox’s Alignment
        2. Specifying the VBox’s Preferred Size
      8. 3.6.8 Adding and Configuring a Label
        1. Adding a Label to the VBox
        2. Changing the Label’s Text
        3. Changing the Label’s Font
      9. 3.6.9 Adding and Configuring an ImageView
        1. Adding an ImageView to the VBox
        2. Setting the ImageView’s Image
        3. Changing the ImageView’s Size
      10. 3.6.10 Previewing the Welcome GUI
        1. GUI and Graphics Case Study Exercise
    9. 3.7 Wrap-Up
    10. Summary
      1. Section 3.2 Instance Variables, set Methods and get Methods
      2. Section 3.2.1 Account Class with an Instance Variable, a set Method and a get Method
      3. Section 3.2.2 AccountTest Class That Creates and Uses an Object of Class Account
      4. Section 3.2.3 Compiling and Executing an App with Multiple Classes
      5. Section 3.2.4 Account UML Class Diagram with an Instance Variable and set and get Methods
      6. Section 3.2.5 Additional Notes on Class AccountTest
      7. Section 3.2.6 Software Engineering with private Instance Variables and public set and get Methods
      8. Section 3.3 Account Class: Initializing Objects with Constructors
      9. Section 3.4 Account Class with a Balance; Floating-Point Numbers
      10. Section 3.5 Primitive Types vs. Reference Types
    11. Self-Review Exercises
    12. Answers to Self-Review Exercises
    13. Exercises
    14. Making a Difference
  17. 4 Control Statements: Part 1; Assignment, ++ and -- Operators
    1. Objectives
    2. Outline
    3. 4.1 Introduction
    4. 4.2 Algorithms
    5. 4.3 Pseudocode
    6. 4.4 Control Structures
      1. 4.4.1 Sequence Structure in Java
      2. 4.4.2 Selection Statements in Java
      3. 4.4.3 Iteration Statements in Java
      4. 4.4.4 Summary of Control Statements in Java
    7. 4.5 if Single-Selection Statement
    8. 4.6 if…else Double-Selection Statement
      1. UML Activity Diagram for an if…else Statement
      2. 4.6.1 Nested if…else Statements
      3. 4.6.2 Dangling-else Problem
      4. 4.6.3 Blocks
      5. 4.6.4 Conditional Operator (?:)
    9. 4.7 Student Class: Nested if…else Statements
    10. 4.8 while Iteration Statement
    11. 4.9 Formulating Algorithms: Counter-Controlled Iteration
    12. 4.10 Formulating Algorithms: Sentinel-Controlled Iteration
    13. 4.11 Formulating Algorithms: Nested Control Statements
    14. 4.12 Compound Assignment Operators
    15. 4.13 Increment and Decrement Operators
    16. 4.14 Primitive Types
    17. 4.15 (Optional) GUI and Graphics Case Study: Event Handling; Drawing Lines
      1. 4.15.1 Test-Driving the Completed Draw Lines App
      2. 4.15.2 Building the App’s GUI
        1. Opening Scene Builder and Creating the File DrawLines.fxml
        2. Creating a BorderPane Layout Container
        3. Adding a ToolBar and Configuring Its Button
        4. Configuring the Button’s Text
        5. Adding and Configuring a Canvas
        6. Setting the Canvas’s Width and Height
        7. Configuring the BorderPane Layout Container’s Size
        8. Saving the Design
      3. 4.15.3 Preparing to Interact with the GUI Programmatically
        1. Specifying the App’s Controller Class
        2. Specifying the Canvas’s Instance Variable Name
        3. Specifying the Button’s Event-Handler Method
        4. Generating the Initial Controller Class
      4. 4.15.4 Class DrawLinesController
        1. @FXML Annotation
        2. Getting a GraphicsContext to Draw on a Canvas
        3. Canvas’s Coordinate System
        4. Drawing Lines
      5. 4.15.5 Class DrawLines—The Main Application Class
        1. GUI and Graphics Case Study Exercises
    18. 4.16 Wrap-Up
    19. 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.4.1 Sequence Structure in Java
      6. Section 4.4.2 Selection Statements in Java
      7. Section 4.4.3 Iteration Statements in Java
      8. Section 4.4.4 Summary of Control Statements in Java
      9. Section 4.5 if Single-Selection Statement
      10. Section 4.6 if…else Double-Selection Statement
      11. Section 4.6.1 Nested if…else Statements
      12. Section 4.6.2 Dangling-else Problem
      13. Section 4.6.3 Blocks
      14. Section 4.6.4 Conditional Operator (?:)
      15. Section 4.8 while Iteration Statement
      16. Section 4.9 Formulating Algorithms: Counter-Controlled Iteration
      17. Section 4.10 Formulating Algorithms: Sentinel-Controlled Iteration
      18. Section 4.12 Compound Assignment Operators
      19. Section 4.13 Increment and Decrement Operators
      20. Section 4.14 Primitive Types
    20. Self-Review Exercises
    21. Answers to Self-Review Exercises
    22. Exercises
    23. Making a Difference
  18. 5 Control Statements: Part 2; Logical Operators
    1. Objectives
    2. Outline
    3. 5.1 Introduction
    4. 5.2 Essentials of Counter-Controlled Iteration
    5. 5.3 for Iteration Statement
    6. 5.4 Examples Using the for Statement
      1. 5.4.1 Application: Summing the Even Integers from 2 to 20
      2. 5.4.2 Application: Compound-Interest Calculations
        1. Formatting Strings with Field Widths and Justification
        2. Performing the Interest Calculations with static Method pow of Class Math
        3. Formatting Floating-Point Numbers
        4. A Warning about Displaying Rounded Values
    7. 5.5 do…while Iteration Statement
    8. 5.6 switch Multiple-Selection Statement
    9. 5.7 Class AutoPolicy Case Study: Strings in switch Statements
    10. 5.8 break and continue Statements
      1. 5.8.1 break Statement
      2. 5.8.2 continue Statement
    11. 5.9 Logical Operators
      1. 5.9.1 Conditional AND (&&) Operator
      2. 5.9.2 Conditional OR (||) Operator
      3. 5.9.3 Short-Circuit Evaluation of Complex Conditions
      4. 5.9.4 Boolean Logical AND (&) and Boolean Logical Inclusive OR (|) Operators
      5. 5.9.5 Boolean Logical Exclusive OR (^)
      6. 5.9.6 Logical Negation (!) Operator
      7. 5.9.7 Logical Operators Example
        1. Precedence and Associativity of the Operators Presented So Far
    12. 5.10 Structured-Programming Summary
    13. 5.11 (Optional) GUI and Graphics Case Study: Drawing Rectangles and Ovals
    14. 5.12 Wrap-Up
    15. Summary
      1. Section 5.2 Essentials of Counter-Controlled Iteration
      2. Section 5.3 for Iteration Statement
      3. Section 5.4.2 Application: Compound-Interest Calculations
      4. Section 5.5 do…while Iteration Statement
      5. Section 5.6 switch Multiple-Selection Statement
      6. Section 5.7 Class AutoPolicy Case Study: Strings in switch Statements
      7. Section 5.8.1 break Statement
      8. Section 5.8.2 continue Statement
      9. Section 5.9 Logical Operators
      10. Section 5.9.1 Conditional AND (&&) Operator
      11. Section 5.9.2 Conditional OR (||) Operator
      12. Section 5.9.3 Short-Circuit Evaluation of Complex Conditions
      13. Section 5.9.4 Boolean Logical AND (&) and Boolean Logical Inclusive OR (|) Operators
      14. Section 5.9.5 Boolean Logical Exclusive OR (^)
      15. Section 5.9.6 Logical Negation (!) Operator
    16. Self-Review Exercises
    17. Answers to Self-Review Exercises
    18. Exercises
    19. Making a Difference
  19. 6 Methods: A Deeper Look
    1. Objectives
    2. Outline
    3. 6.1 Introduction
    4. 6.2 Program Units in Java
    5. 6.3 static Methods, static Fields and Class Math
    6. 6.4 Methods with Multiple Parameters
    7. 6.5 Notes on Declaring and Using Methods
    8. 6.6 Method-Call Stack and Activation Records
      1. 6.6.1 Method-Call Stack
      2. 6.6.2 Stack Frames
      3. 6.6.3 Local Variables and Stack Frames
      4. 6.6.4 Stack Overflow
    9. 6.7 Argument Promotion and Casting
    10. 6.8 Java API Packages
    11. 6.9 Case Study: Secure Random-Number Generation
    12. 6.10 Case Study: A Game of Chance; Introducing enum Types
    13. 6.11 Scope of Declarations
    14. 6.12 Method Overloading
      1. 6.12.1 Declaring Overloaded Methods
      2. 6.12.2 Distinguishing Between Overloaded Methods
      3. 6.12.3 Return Types of Overloaded Methods
    15. 6.13 (Optional) GUI and Graphics Case Study: Colors and Filled Shapes
    16. 6.14 Wrap-Up
    17. Summary
      1. Section 6.1 Introduction
      2. Section 6.2 Program Units in Java
      3. Section 6.3 static Methods, static Fields and Class Math
      4. Section 6.4 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: Secure Random-Number Generation
      9. Section 6.10 Case Study: A Game of Chance; Introducing enum Types
      10. Section 6.11 Scope of Declarations
      11. Section 6.12 Method Overloading
    18. Self-Review Exercises
    19. Answers to Self-Review Exercises
    20. Exercises
    21. Making a Difference
  20. 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. 7.4.1 Creating and Initializing an Array
      2. 7.4.2 Using an Array Initializer
      3. 7.4.3 Calculating the Values to Store in an Array
      4. 7.4.4 Summing the Elements of an Array
      5. 7.4.5 Using Bar Charts to Display Array Data Graphically
      6. 7.4.6 Using the Elements of an Array as Counters
      7. 7.4.7 Using Arrays to Analyze Survey Results
        1. The frequency Array
        2. Summarizing the Results
    7. 7.5 Exception Handling: Processing the Incorrect Response
      1. 7.5.1 The try Statement
      2. 7.5.2 Executing the catch Block
      3. 7.5.3 toString Method of the Exception Parameter
    8. 7.6 Case Study: Card Shuffling and Dealing Simulation
    9. 7.7 Enhanced for Statement
    10. 7.8 Passing Arrays to Methods
    11. 7.9 Pass-By-Value vs. Pass-By-Reference
    12. 7.10 Case Study: Class GradeBook Using an Array to Store Grades
    13. 7.11 Multidimensional Arrays
      1. 7.11.1 Arrays of One-Dimensional Arrays
      2. 7.11.2 Two-Dimensional Arrays with Rows of Different Lengths
      3. 7.11.3 Creating Two-Dimensional Arrays with Array-Creation Expressions
      4. 7.11.4 Two-Dimensional Array Example: Displaying Element Values
      5. 7.11.5 Common Multidimensional-Array Manipulations Performed with for Statements
    14. 7.12 Case Study: Class GradeBook Using a Two-Dimensional Array
    15. 7.13 Variable-Length Argument Lists
    16. 7.14 Using Command-Line Arguments
    17. 7.15 Class Arrays
    18. 7.16 Introduction to Collections and Class ArrayList
    19. 7.17 (Optional) GUI and Graphics Case Study: Drawing Arcs
    20. 7.18 Wrap-Up
    21. Summary
      1. Section 7.1 Introduction
      2. Section 7.2 Arrays
      3. Section 7.3 Declaring and Creating Arrays
      4. Section 7.4 Examples Using Arrays
      5. Section 7.5 Exception Handling: Processing the Incorrect Response
      6. Section 7.6 Case Study: Card Shuffling and Dealing Simulation
      7. Section 7.7 Enhanced for Statement
      8. Section 7.8 Passing Arrays to Methods
      9. Section 7.9 Pass-By-Value vs. Pass-By-Reference
      10. Section 7.11 Multidimensional Arrays
      11. Section 7.13 Variable-Length Argument Lists
      12. Section 7.14 Using Command-Line Arguments
      13. Section 7.15 Class Arrays
      14. Section 7.16 Introduction to Collections and Class ArrayList
    22. Self-Review Exercises
    23. Answers to Self-Review Exercises
    24. Exercises
    25. Special Section: Building Your Own Computer
    26. Making a Difference
  21. 8 Classes and Objects: A Deeper Look
    1. Objectives
    2. Outline
    3. 8.1 Introduction
    4. 8.2 Time Class Case Study
    5. 8.3 Controlling Access to Members
    6. 8.4 Referring to the Current Object’s Members with the this Reference
    7. 8.5 Time Class Case Study: Overloaded Constructors
    8. 8.6 Default and No-Argument Constructors
    9. 8.7 Notes on Set and Get Methods
    10. 8.8 Composition
    11. 8.9 enum Types
    12. 8.10 Garbage Collection
    13. 8.11 static Class Members
    14. 8.12 static Import
    15. 8.13 final Instance Variables
    16. 8.14 Package Access
    17. 8.15 Using BigDecimal for Precise Monetary Calculations
    18. 8.16 (Optional) GUI and Graphics Case Study: Using Objects with Graphics
    19. 8.17 Wrap-Up
    20. 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 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 enum Types
      9. Section 8.10 Garbage Collection
      10. Section 8.11 static Class Members
      11. Section 8.12 static Import
      12. Section 8.13 final Instance Variables
      13. Section 8.14 Package Access
      14. Section 8.15 Using BigDecimal for Precise Monetary Calculations
    21. Self-Review Exercises
    22. Answers to Self-Review Exercises
    23. Exercises
    24. Making a Difference
  22. 9 Object-Oriented Programming: Inheritance
    1. Objectives
    2. Outline
    3. 9.1 Introduction
    4. 9.2 Superclasses and Subclasses
    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
        2. Class CommissionEmployee’s Constructor
        3. Class CommissionEmployee’s earnings Method
        4. Class CommissionEmployee’s toString Method
        5. @Override Annotaton
        6. Class CommissionEmployeeTest
      2. 9.4.2 Creating and Using a BasePlusCommissionEmployee Class
        1. Testing Class BasePlusCommissionEmployee
        2. 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 Methods Earnings and toString
      4. 9.4.4 CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy Using protected Instance Variables
        1. Class BasePlusCommissionEmployee
        2. A Subclass Object Contains the Instance Variables of All of Its Superclasses
        3. Testing Class BasePlusCommissionEmployee
        4. Notes on Using protected Instance Variables
      5. 9.4.5 CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy Using private Instance Variables
        1. Class CommissionEmployee
        2. Class BasePlusCommissionEmployee
        3. Class BasePlusCommissionEmployee’s earnings Method
        4. Class BasePlusCommissionEmployee’s toString Method
        5. Testing Class BasePlusCommissionEmployee
    7. 9.5 Constructors in Subclasses
    8. 9.6 Class Object
    9. 9.7 Designing with Composition vs. Inheritance
    10. 9.8 Wrap-Up
    11. 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 Class Object
    12. Self-Review Exercises
    13. Answers to Self-Review Exercises
    14. Exercises
  23. 10 Object-Oriented Programming: Polymorphism and Interfaces
    1. Objectives
    2. Outline
    3. 10.1 Introduction
    4. 10.2 Polymorphism Examples
    5. 10.3 Demonstrating Polymorphic Behavior
    6. 10.4 Abstract Classes and Methods
    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. Getting Each Employee’s Class Name
        6. Avoiding Compilation Errors with Downcasting
    8. 10.6 Allowed Assignments Between Superclass and Subclass Variables
    9. 10.7 final Methods and Classes
    10. 10.8 A Deeper Explanation of Issues with Calling Methods from Constructors
    11. 10.9 Creating and Using Interfaces
      1. 10.9.1 Developing a Payable Hierarchy
        1. UML Diagram Containing an Interface
      2. 10.9.2 Interface Payable
      3. 10.9.3 Class Invoice
        1. A Class Can Extend Only One Other Class But Can Implement Many Interfaces
      4. 10.9.4 Modifying Class Employee to Implement Interface Payable
        1. Subclasses of Employee and Interface Payable
      5. 10.9.5 Using Interface Payable to Process Invoices and Employees Polymorphically
      6. 10.9.6 Some Common Interfaces of the Java API
    12. 10.10 Java SE 8 Interface Enhancements
      1. 10.10.1 default Interface Methods
        1. Adding Methods to Existing Interfaces
        2. Interfaces vs. abstract Classes
      2. 10.10.2 static Interface Methods
      3. 10.10.3 Functional Interfaces
    13. 10.11 Java SE 9 private Interface Methods
    14. 10.12 private Constructors
    15. 10.13 Program to an Interface, Not an Implementation3
      1. 10.13.1 Implementation Inheritance Is Best for Small Numbers of Tightly Coupled Classes
      2. 10.13.2 Interface Inheritance Is Best for Flexibility
      3. 10.13.3 Rethinking the Employee Hierarchy
        1. Flexibility if Compensation Models Change
        2. Flexibility if Employees Are Promoted
        3. Flexibility if Employees Acquire New Capabilities
    16. 10.14 (Optional) GUI and Graphics Case Study: Drawing with Polymorphism
    17. 10.15 Wrap-Up
    18. 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 Allowed Assignments Between Superclass and Subclass Variables
      6. Section 10.7 final Methods and Classes
      7. Section 10.8 A Deeper Explanation of Issues with Calling Methods from Constructors
      8. Section 10.9 Creating and Using Interfaces
      9. Section 10.10 Java SE 8 Interface Enhancements
      10. Section 10.11 Java SE 9 private Interface Methods
      11. Section 10.12 private Constructors
      12. Section 10.13 Program to an Interface, Not an Implementation
    19. Self-Review Exercises
    20. Answers to Self-Review Exercises
    21. Exercises
    22. Making a Difference
  24. 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
    6. 11.4 When to Use Exception Handling
    7. 11.5 Java Exception Hierarchy
    8. 11.6 finally Block
    9. 11.7 Stack Unwinding and Obtaining Information from an Exception
    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 try-with-Resources: Automatic Resource Deallocation
    15. 11.13 Wrap-Up
    16. 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
      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 try-with-Resources: Automatic Resource Deallocation
    17. Self-Review Exercises
    18. Answers to Self-Review Exercises
    19. Exercises
  25. 12 JavaFX Graphical User Interfaces: Part 1
    1. Objectives
    2. Outline
    3. 12.1 Introduction
    4. 12.2 JavaFX Scene Builder
    5. 12.3 JavaFX App Window Structure
    6. 12.4 Welcome App—Displaying Text and an Image
      1. 12.4.1 Opening Scene Builder and Creating the File Welcome.fxml
      2. 12.4.2 Adding an Image to the Folder Containing Welcome.fxml
      3. 12.4.3 Creating a VBox Layout Container
      4. 12.4.4 Configuring the VBox Layout Container
        1. Specifying the VBox’s Alignment
        2. Specifying the VBox’s Preferred Size
      5. 12.4.5 Adding and Configuring a Label
        1. Adding a Label to the VBox
        2. Changing the Label’s Text
        3. Changing the Label’s Font
      6. 12.4.6 Adding and Configuring an ImageView
        1. Adding an ImageView to the VBox
        2. Setting the ImageView’s Image
        3. Changing the ImageView’s Size
      7. 12.4.7 Previewing the Welcome GUI
    7. 12.5 Tip Calculator App—Introduction to Event Handling
      1. 12.5.1 Test-Driving the Tip Calculator App
        1. Entering a Bill Total
        2. Selecting a Custom Tip Percentage
      2. 12.5.2 Technologies Overview
        1. Class Application
        2. Arranging JavaFX Components with a GridPane
        3. Creating and Customizing the GUI with Scene Builder
        4. Formatting Numbers as Locale-Specific Currency and Percentage Strings
        5. Event Handling
        6. Implementing Interface ChangeListener for Handling Slider Thumb Position Changes
        7. Model-View-Controller (MVC) Architecture
        8. FXMLLoader Class
      3. 12.5.3 Building the App’s GUI
        1. fx:id Property Values for This App’s Controls
        2. Creating the TipCalculator.fxml File
        3. Step 1: Adding a GridPane
        4. Step 2: Adding Rows to the GridPane
        5. Step 3: Adding the Controls to the GridPane
        6. Step 4: Sizing the GridPane to Fit Its Contents
        7. Step 5: Right-Aligning GridPane Column 0’s Contents
        8. Step 6: Sizing the GridPane Columns to Fit Their Contents
        9. Step 7: Sizing the Button
        10. Previewing the GUI
        11. Step 8: Configuring the GridPane’s Padding and Horizontal Gap Between Its Columns
        12. Step 9: Making the tipTextField and totalTextField Uneditable and Not Focusable
        13. Step 10: Setting the Slider’s Properties
        14. Previewing the Final Layout
        15. Specifying the Controller Class’s Name
        16. Specifying the Calculate Button’s Event-Handler Method Name
        17. Generating a Sample Controller Class
      4. 12.5.4 TipCalculator Class
        1. Overridden Application Method start
        2. Creating the Scene
      5. 12.5.5 TipCalculatorController Class
        1. Class TipCalculatorController’s import Statements
        2. TipCalculatorController’s static Variables and Instance Variables
        3. @FXML Annotation
        4. TipCalculatorController’s calculateButtonPressed Event Handler
        5. Registering the Calculate Button’s Event Handler
        6. Calculating and Displaying the Tip and Total Amounts
        7. TipCalculatorController’s initalize Method
        8. Using an Anonymous Inner Class for Event Handling
        9. Anonymous Inner Class Notes
        10. Java SE 8: Using a Lambda to Implement the ChangeListener
    8. 12.6 Features Covered in the Other JavaFX Chapters
    9. 12.7 Wrap-Up
    10. Summary
      1. Section 12.1 Introduction
      2. Section 12.2 JavaFX Scene Builder
      3. Section 12.3 JavaFX App Window Structure
      4. Section 12.4 Welcome App—Displaying Text and an Image
      5. Section 12.5.2 Technologies Overview
      6. Section 12.5.3 Building the App’s GUI
      7. Section 12.5.4 TipCalculator Class
      8. Section 12.5.5 TipCalculatorController Class
    11. Self-Review Exercises
    12. Answers to Self-Review Exercises
    13. Exercises
    14. Making a Difference
  26. 13 JavaFX GUI: Part 2
    1. Objectives
    2. Outline
    3. 13.1 Introduction
    4. 13.2 Laying Out Nodes in a Scene Graph
    5. 13.3 Painter App: RadioButtons, Mouse Events and Shapes
      1. 13.3.1 Technologies Overview
        1. RadioButtons and ToggleGroups
        2. BorderPane Layout Container
        3. TitledPane Layout Container
        4. JavaFX Shapes
        5. Pane Layout Container
        6. Mouse Event Handling
        7. Setting a Control’s User Data
      2. 13.3.2 Creating the Painter.fxml File
      3. 13.3.3 Building the GUI
        1. fx:id Property Values for This App’s Controls
        2. Step 1: Adding a BorderPane as the Root Layout Node
        3. Step 2: Configuring the BorderPane
        4. Step 3: Adding the VBox and Pane
        5. Step 4: Adding the TitledPanes to the VBox
        6. Step 5: Customizing the TitledPanes
        7. Step 6: Adding the RadioButtons to the VBox
        8. Step 7: Specifying the ToggleGroups for the RadioButtons
        9. Step 8: Changing the TitledPanes’ Preferred Width and Height
        10. Step 9: Adding the Buttons
        11. Step 10: Setting the Width the VBox
        12. Step 11: Specifying the Controller Class’s Name
        13. Step 12: Specifying the Event-Handler Method Names
        14. Step 13: Generating a Sample Controller Class
      4. 13.3.4 Painter Subclass of Application
      5. 13.3.5 PainterController Class
        1. PenSize enum
        2. Instance Variables
        3. Method initialize
        4. drawingAreaMouseDragged Event Handler
        5. colorRadioButtonSelected Event Handler
        6. sizeRadioButtonSelected Event Handler
        7. undoButtonPressed Event Handler
        8. clearButtonPressed Event Handler
    6. 13.4 Color Chooser App: Property Bindings and Property Listeners
      1. 13.4.1 Technologies Overview
        1. RGBA Colors
        2. Properties of a Class
        3. Property Bindings
        4. Property Listeners
      2. 13.4.2 Building the GUI
        1. fx:id Property Values for This App’s Controls
        2. Step 1: Adding a GridPane
        3. Step 2: Configuring the GridPane
        4. Step 3: Adding the Controls
        5. Step 4: Configuring the Sliders
        6. Step 5: Configuring the TextFields
        7. Step 6: Configuring the Rectangle
        8. Step 7: Configuring the Circle
        9. Step 8: Configuring the Rows
        10. Step 9: Configuring the Columns
        11. Step 10: Configuring the GridPane
        12. Step 11: Specifying the Controller Class’s Name
        13. Step 12: Generating a Sample Controller Class
      3. 13.4.3 ColorChooser Subclass of Application
      4. 13.4.4 ColorChooserController Class
        1. Instance Variables
        2. Method initialize
        3. Property-to-Property Bindings
        4. Property Listeners
    7. 13.5 Cover Viewer App: Data-Driven GUIs with JavaFX Collections
      1. 13.5.1 Technologies Overview
      2. 13.5.2 Adding Images to the App’s Folder
      3. 13.5.3 Building the GUI
        1. fx:id Property Values for This App’s Controls
        2. Adding and Configuring the Controls
        3. Specifying the Controller Class’s Name
        4. Generating a Sample Controller Class
      4. 13.5.4 CoverViewer Subclass of Application
      5. 13.5.5 CoverViewerController Class
        1. @FXML Instance Variables
        2. Instance Variable books
        3. Initializing the books ObservableList
        4. Listening for ListView Selection Changes
    8. 13.6 Cover Viewer App: Customizing ListView Cells
      1. 13.6.1 Technologies Overview
        1. ListCell Generic Class for Custom ListView Cell Formats
        2. Programmatically Creating Layouts and Controls
      2. 13.6.2 Copying the CoverViewer App
      3. 13.6.3 ImageTextCell Custom Cell Factory Class
        1. Constructor
        2. Method updateItem
      4. 13.6.4 CoverViewerController Class
    9. 13.7 Additional JavaFX Capabilities
    10. 13.8 JavaFX 9: Java SE 9 JavaFX Updates
    11. 13.9 Wrap-Up
    12. Summary
      1. Section 13.2 Laying Out Nodes in a Scene Graph
      2. Section 13.3.1 Technologies Overview
      3. Section 13.3.2 Creating the Painter.fxml File
      4. Section 13.3.3 Building the GUI
      5. Section 13.3.5 PainterController Class
      6. Section 13.4.1 Technologies Overview
      7. Section 13.4.2 Building the GUI
      8. Section 13.4.4 ColorChooserController Class
      9. Section 13.5 Cover Viewer App: Data-Driven GUIs with JavaFX Collections
      10. Section 13.5.1 Technologies Overview
      11. Section 13.5.5 CoverViewerController Class
      12. Section 13.6.1 Technologies Overview
      13. Section 13.6.3 ImageTextCell Custom Cell Factory Class
      14. Section 13.6.4 CoverViewerController Class
      15. Section 13.7 Additional JavaFX Capabilities
      16. Section 13.8 JavaFX 9: Java SE 9 JavaFX Updates
    13. Self-Review Exercises
    14. Answers to Self-Review Exercises
    15. Exercises
      1. (Optional) GUI and Graphics Case Study Exercise: Interactive Polymorphic Drawing App
  27. 14 Strings, Characters and Regular Expressions
    1. Objectives
    2. Outline
    3. 14.1 Introduction
    4. 14.2 Fundamentals of Characters and Strings
    5. 14.3 Class String
      1. 14.3.1 String Constructors
      2. 14.3.2 String Methods length, charAt and getChars
      3. 14.3.3 Comparing Strings
        1. String Method equals
        2. Comparing Strings with the == Operator
        3. String Method equalsIgnoreCase
        4. String Method compareTo
        5. String Method regionMatches
        6. String Methods startsWith and endsWith
      4. 14.3.4 Locating Characters and Substrings in Strings
      5. 14.3.5 Extracting Substrings from Strings
      6. 14.3.6 Concatenating Strings
      7. 14.3.7 Miscellaneous String Methods
      8. 14.3.8 String Method valueOf
    6. 14.4 Class StringBuilder
      1. 14.4.1 StringBuilder Constructors
      2. 14.4.2 StringBuilder Methods length, capacity, setLength and ensureCapacity
      3. 14.4.3 StringBuilder Methods charAt, setCharAt, getChars and reverse
      4. 14.4.4 StringBuilder append Methods
      5. 14.4.5 StringBuilder Insertion and Deletion Methods
    7. 14.5 Class Character
    8. 14.6 Tokenizing Strings
    9. 14.7 Regular Expressions, Class Pattern and Class Matcher
      1. 14.7.1 Replacing Substrings and Splitting Strings
      2. 14.7.2 Classes Pattern and Matcher
        1. Java SE 8
        2. Java SE 9: New Matcher Methods
    10. 14.8 Wrap-Up
    11. Summary
      1. Section 14.2 Fundamentals of Characters and Strings
      2. Section 14.3 Class String
      3. Section 14.4 Class StringBuilder
      4. Section 14.5 Class Character
      5. Section 14.6 Tokenizing Strings
      6. Section 14.7 Regular Expressions, Class Pattern and Class Matcher
    12. Self-Review Exercises
    13. Answers to Self-Review Exercises
    14. Exercises
    15. Special Section: String-Manipulation Exercises
    16. Special Section: Challenging String-Manipulation Projects
    17. Making a Difference
  28. 15 Files, Input/Output Streams, NIO and XML Serialization
    1. Objectives
    2. Outline
    3. 15.1 Introduction
    4. 15.2 Files and Streams
    5. 15.3 Using NIO Classes and Interfaces to Get File and Directory Information
    6. 15.4 Sequential Text Files
      1. 15.4.1 Creating a Sequential Text File
        1. Class CreateTextFile
        2. Writing Data to the File
        3. Sample Output
      2. 15.4.2 Reading Data from a Sequential Text File
      3. 15.4.3 Case Study: A Credit-Inquiry Program
        1. MenuOption enum
        2. CreditInquiry Class
      4. 15.4.4 Updating Sequential Files
    7. 15.5 XML Serialization
      1. 15.5.1 Creating a Sequential File Using XML Serialization
        1. Declaring Class Account
        2. Plain Old Java Objects
        3. Declaring Class Accounts
        4. Writing XML Serialized Objects to a File
        5. The XML Output
      2. 15.5.2 Reading and Deserializing Data from a Sequential File
    8. 15.6 FileChooser and DirectoryChooser Dialogs
    9. 15.7 (Optional) Additional java.io Classes
      1. 15.7.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. 15.7.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
    10. 15.8 Wrap-Up
    11. Summary
      1. Section 15.1 Introduction
      2. Section 15.2 Files and Streams
      3. Section 15.3 Using NIO Classes and Interfaces to Get File and Directory Information
      4. Section 15.4 Sequential Text Files
      5. Section 15.5 XML Serialization
      6. Section 15.5.1 Creating a Sequential File Using XML Serialization
      7. Section 15.5.2 Reading and Deserializing Data from a Sequential File
      8. Section 15.6 FileChooser and DirectoryChooser Dialogs
      9. Section 15.7 (Optional) Additional java.io Classes
    12. Self-Review Exercises
    13. Answers to Self-Review Exercises
    14. Exercises
    15. Making a Difference
  29. 16 Generic Collections
    1. Objectives
    2. Outline
    3. 16.1 Introduction
    4. 16.2 Collections Overview
    5. 16.3 Type-Wrapper Classes
    6. 16.4 Autoboxing and Auto-Unboxing
    7. 16.5 Interface Collection and Class Collections
    8. 16.6 Lists
      1. 16.6.1 ArrayList and Iterator
        1. Type Inference with the <> Notation
      2. 16.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. 16.7 Collections Methods
      1. 16.7.1 Method sort
        1. Sorting in Ascending Order
        2. Sorting in Descending Order
        3. Sorting with a Comparator
      2. 16.7.2 Method shuffle
      3. 16.7.3 Methods reverse, fill, copy, max and min
      4. 16.7.4 Method binarySearch
      5. 16.7.5 Methods addAll, frequency and disjoint
    10. 16.8 Class PriorityQueue and Interface Queue
    11. 16.9 Sets
    12. 16.10 Maps
    13. 16.11 Synchronized Collections
    14. 16.12 Unmodifiable Collections
    15. 16.13 Abstract Implementations
    16. 16.14 Java SE 9: Convenience Factory Methods for Immutable Collections1
    17. 16.15 Wrap-Up
    18. Summary
      1. Section 16.1 Introduction
      2. Section 16.2 Collections Overview
      3. Section 16.3 Type-Wrapper Classes
      4. Section 16.4 Autoboxing and Auto-Unboxing
      5. Section 16.5 Interface Collection and Class Collections
      6. Section 16.6 Lists
      7. Section 16.7 Collections Methods
      8. Section 16.8 Class PriorityQueue and Interface Queue
      9. Section 16.9 Sets
      10. Section 16.10 Maps
      11. Section 16.11 Synchronized Collections
      12. Section 16.12 Unmodifiable Collections
      13. Section 16.13 Abstract Implementations
      14. Section 16.14 Java SE 9: Convenience Factory Methods for Immutable Collections
    19. Self-Review Exercises
    20. Answers to Self-Review Exercises
    21. Exercises
  30. 17 Lambdas and Streams
    1. Objectives
    2. Outline
    3. 17.1 Introduction1
    4. 17.2 Streams and Reduction
      1. 17.2.1 Summing the Integers from 1 through 10 with a for Loop
      2. 17.2.2 External Iteration with for Is Error Prone
      3. 17.2.3 Summing with a Stream and Reduction
        1. Streams and Stream Pipelines
        2. Specifying the Data Source
        3. Calculating the Sum of the IntStream’s Elements
        4. Processing the Stream Pipeline
      4. 17.2.4 Internal Iteration
    5. 17.3 Mapping and Lambdas
      1. 17.3.1 Lambda Expressions
      2. 17.3.2 Lambda Syntax
        1. Eliminating a Lambda’s Parameter Type(s)
        2. Simplifying the Lambda’s Body
        3. Simplifying the Lambda’s Parameter List
        4. Lambdas with Empty Parameter Lists
        5. Method References
      3. 17.3.3 Intermediate and Terminal Operations
        1. Lazy and Eager Operations
    6. 17.4 Filtering
    7. 17.5 How Elements Move Through Stream Pipelines
    8. 17.6 Method References
      1. 17.6.1 Creating an IntStream of Random Values
      2. 17.6.2 Performing a Task on Each Stream Element with forEach and a Method Reference
      3. 17.6.3 Mapping Integers to String Objects with mapToObj
      4. 17.6.4 Concatenating Strings with collect
    9. 17.7 IntStream Operations
      1. 17.7.1 Creating an IntStream and Displaying Its Values
      2. 17.7.2 Terminal Operations count, min, max, sum and average
      3. 17.7.3 Terminal Operation reduce
        1. Calculating the Product of the Values with Method reduce
        2. Summing the Squares of the Values
      4. 17.7.4 Sorting IntStream Values
    10. 17.8 Functional Interfaces
    11. 17.9 Lambdas: A Deeper Look
    12. 17.10 Stream<Integer> Manipulations
      1. 17.10.1 Creating a Stream<Integer>
      2. 17.10.2 Sorting a Stream and Collecting the Results
        1. Creating a New Collection Containing a Stream Pipeline’s Results
        2. 17.10.3 Filtering a Stream and Storing the Results for Later Use
      3. 17.10.4 Filtering and Sorting a Stream and Collecting the Results
      4. 17.10.5 Sorting Previously Collected Results
    13. 17.11 Stream<String> Manipulations
      1. 17.11.1 Mapping Strings to Uppercase
      2. 17.11.2 Filtering Strings Then Sorting Them in Case-Insensitive Ascending Order
      3. 17.11.3 Filtering Strings Then Sorting Them in Case-Insensitive Descending Order
    14. 17.12 Stream<Employee> Manipulations
      1. 17.12.1 Creating and Displaying a List<Employee>
        1. Java SE 9: Creating an Immutable List<Employee> with List Method of
      2. 17.12.2 Filtering Employees with Salaries in a Specified Range
        1. Short-Circuit Stream Pipeline Processing
      3. 17.12.3 Sorting Employees By Multiple Fields
        1. Aside: Composing Lambda Expressions
      4. 17.12.4 Mapping Employees to Unique-Last-Name Strings
      5. 17.12.5 Grouping Employees By Department
      6. 17.12.6 Counting the Number of Employees in Each Department
      7. 17.12.7 Summing and Averaging Employee Salaries
    15. 17.13 Creating a Stream<String> from a File
    16. 17.14 Streams of Random Values
    17. 17.15 Infinite Streams
    18. 17.16 Lambda Event Handlers
    19. 17.17 Additional Notes on Java SE 8 Interfaces
    20. 17.18 Wrap-Up
    21. Summary
      1. Section 17.1 Introduction
      2. Section 17.2 Streams and Reduction
      3. Section 17.2.1 Summing the Integers from 1 through 10 with a for Loop
      4. Section 17.2.2 External Iteration with for Is Error Prone
      5. Section 17.2.3 Summing with a Stream and Reduction
      6. Section 17.2.4 Internal Iteration
      7. Section 17.3 Mapping and Lambdas
      8. Section 17.3.1 Lambda Expressions
      9. Section 17.3.2 Lambda Syntax
      10. Section 17.3.3 Intermediate and Terminal Operations
      11. Section 17.4 Filtering
      12. Section 17.5 How Elements Move Through Stream Pipelines
      13. Section 17.6 Method References
      14. Section 17.6.1 Creating an IntStream of Random Values
      15. Section 17.6.2 Performing a Task on Each Stream Element with forEach and a Method Reference
      16. Section 17.6.3 Mapping Integers to String Objects with mapToObj
      17. Section 17.6.4 Concatenating Strings with collect
      18. Section 17.7 IntStream Operations
      19. Section 17.7.1 Creating an IntStream and Displaying Its Values
      20. Section 17.7.2 Terminal Operations count, min, max, sum and average
      21. Section 17.7.3 Terminal Operation reduce
      22. Section 17.7.4 Sorting IntStream Values
      23. Section 17.8 Functional Interfaces
      24. Section 17.9 Lambdas: A Deeper Look
      25. Section 17.10 Stream<Integer> Manipulations
      26. Section 17.10.1 Creating a Stream<Integer>
      27. Section 17.10.2 Sorting a Stream and Collecting the Results
      28. Section 17.10.3 Filtering a Stream and Storing the Results for Later Use
      29. Section 17.10.5 Sorting Previously Collected Results
      30. Section 17.11.1 Mapping Strings to Uppercase
      31. Section 17.11.2 Filtering Strings Then Sorting Them in Case-Insensitive Ascending Order
      32. Section 17.11.3 Filtering Strings Then Sorting Them in Case-Insensitive Descending Order
      33. Section 17.12.1 Creating and Displaying a List<Employee>
      34. Section 17.12.2 Filtering Employees with Salaries in a Specified Range
      35. Section 17.12.3 Sorting Employees By Multiple Fields
      36. Section 17.12.4 Mapping Employees to Unique Last Name Strings
      37. Section 17.12.5 Grouping Employees By Department
      38. Section 17.12.6 Counting the Number of Employees in Each Department
      39. Section 17.12.7 Summing and Averaging Employee Salaries
      40. Section 17.13 Creating a Stream<String> from a File
      41. Section 17.14 Streams of Random Values
      42. Section 17.15 Infinite Streams
      43. Section 17.16 Lambda Event Handlers
      44. Section 17.17 Additional Notes on Java SE 8 Interfaces
    22. Self-Review Exercises
    23. Answers to Self-Review Exercises
    24. Exercises
  31. 18 Recursion
    1. Objectives
    2. Outline
    3. 18.1 Introduction
    4. 18.2 Recursion Concepts
    5. 18.3 Example Using Recursion: Factorials
    6. 18.4 Reimplementing Class FactorialCalculator Using BigInteger
    7. 18.5 Example Using Recursion: Fibonacci Series
    8. 18.6 Recursion and the Method-Call Stack
    9. 18.7 Recursion vs. Iteration
    10. 18.8 Towers of Hanoi
    11. 18.9 Fractals
      1. 18.9.1 Koch Curve Fractal
      2. 18.9.2 (Optional) Case Study: Lo Feather Fractal
      3. 18.9.3 (Optional) Fractal App GUI
        1. ToolBar and Its Additional Controls
        2. ColorPicker
        3. Event Handlers
      4. 18.9.4 (Optional) FractalController Class
        1. FractalController Fields
        2. initialize Method
        3. colorSelected Event Handler
        4. decreaseLevelButtonPressed and increaseLevelButtonPressed Event Handlers
        5. drawFractal Method with No Arguments
        6. drawFractal Method with Five Arguments
    12. 18.10 Recursive Backtracking
    13. 18.11 Wrap-Up
    14. Summary
      1. Section 18.1 Introduction
      2. Section 18.2 Recursion Concepts
      3. Section 18.3 Example Using Recursion: Factorials
      4. Section 18.5 Example Using Recursion: Fibonacci Series
      5. Section 18.6 Recursion and the Method-Call Stack
      6. Section 18.7 Recursion vs. Iteration
      7. Section 18.9 Fractals
      8. Section 18.10 Recursive Backtracking
    15. Self-Review Exercises
    16. Answers to Self-Review Exercises
    17. Exercises
      1. Lambdas and Streams Exercises
  32. 19 Searching, Sorting and Big O
    1. Objectives
    2. Outline
    3. 19.1 Introduction
    4. 19.2 Linear Search
    5. 19.3 Big O Notation
      1. 19.3.1 O(1) Algorithms
      2. 19.3.2 O(n) Algorithms
      3. 19.3.3 O(n2) Algorithms
      4. 19.3.4 Big O of the Linear Search
    6. 19.4 Binary Search
      1. 19.4.1 Binary Search Implementation
      2. 19.4.2 Efficiency of the Binary Search
    7. 19.5 Sorting Algorithms
    8. 19.6 Selection Sort
      1. 19.6.1 Selection Sort Implementation
        1. Methods selectionSort and swap
        2. Methods printPass
      2. 19.6.2 Efficiency of the Selection Sort
    9. 19.7 Insertion Sort
      1. 19.7.1 Insertion Sort Implementation
        1. Method insertionSort
        2. Method printPass
      2. 19.7.2 Efficiency of the Insertion Sort
    10. 19.8 Merge Sort
      1. 19.8.1 Merge Sort Implementation
        1. Method mergeSort
        2. Recursive Method sortArray
        3. Method merge
      2. 19.8.2 Efficiency of the Merge Sort
    11. 19.9 Big O Summary for This Chapter’s Searching and Sorting Algorithms
    12. 19.10 Massive Parallelism and Parallel Algorithms
    13. 19.11 Wrap-Up
    14. Summary
      1. Section 19.1 Introduction
      2. Section 19.2 Linear Search
      3. Section 19.3 Big O Notation
      4. Section 19.4 Binary Search
      5. Section 19.6 Selection Sort
      6. Section 19.7 Insertion Sort
      7. Section 19.8 Merge Sort
    15. Self-Review Exercises
    16. Answers to Self-Review Exercises
    17. Exercises
    18. Making a Difference
  33. 20 Generic Classes and Methods: A Deeper Look
    1. Objectives
    2. Outline
    3. 20.1 Introduction
    4. 20.2 Motivation for Generic Methods
    5. 20.3 Generic Methods: Implementation and Compile-Time Translation
    6. 20.4 Additional Compile-Time Translation Issues: Methods That Use a Type Parameter as the Return Type
    7. 20.5 Overloading Generic Methods
    8. 20.6 Generic Classes
    9. 20.7 Wildcards in Methods That Accept Type Parameters
    10. 20.8 Wrap-Up
    11. Summary
      1. Section 20.1 Introduction
      2. Section 20.2 Motivation for Generic Methods
      3. Section 20.3 Generic Methods: Implementation and Compile-Time Translation
      4. Section 20.4 Additional Compile-Time Translation Issues: Methods That Use a Type Parameter as the Return Type
      5. Section 20.5 Overloading Generic Methods
      6. Section 20.6 Generic Classes
      7. Section 20.7 Wildcards in Methods That Accept Type Parameters
    12. Self-Review Exercises
    13. Answers to Self-Review Exercises
    14. Exercises
  34. 21 Custom Generic Data Structures
    1. Objectives
    2. Outline
    3. 21.1 Introduction
    4. 21.2 Self-Referential Classes
    5. 21.3 Dynamic Memory Allocation
    6. 21.4 Linked Lists
      1. 21.4.1 Singly Linked Lists
      2. 21.4.2 Implementing a Generic List Class
      3. 21.4.3 Generic Classes ListNode and List
      4. 21.4.4 Class ListTest
      5. 21.4.5 List Method insertAtFront
      6. 21.4.6 List Method insertAtBack
      7. 21.4.7 List Method removeFromFront
      8. 21.4.8 List Method removeFromBack
      9. 21.4.9 List Method print
      10. 21.4.10 Creating Your Own Packages
        1. Steps for Declaring a Reusable Class
        2. Step 1: Creating public Types for Reuse
        3. Step 2: Adding the package Statements
        4. Package Naming Conventions
        5. Fully Qualified Names
        6. Step 3: Compiling Packaged Types
        7. Step 4: Importing Types from Your Package
        8. Single-Type-Import vs. Type-Import-On-Demand Declarations
        9. Specifying the Classpath When Compiling a Program
        10. Specifying the Classpath When Executing a Program
    7. 21.5 Stacks
    8. 21.6 Queues
    9. 21.7 Trees
    10. 21.8 Wrap-Up
    11. Summary
      1. Section 21.1 Introduction
      2. Section 21.2 Self-Referential Classes
      3. Section 21.3 Dynamic Memory Allocation
      4. Section 21.4 Linked Lists
      5. Section 21.5 Stacks
      6. Section 21.6 Queues
      7. Section 21.7 Trees
    12. Self-Review Exercises
    13. Answers to Self-Review Exercises
    14. Exercises
    15. Special Section: Building Your Own Compiler
      1. First Pass
      2. Second Pass
      3. A Complete Example
      4. A Step-by-Step View of the Compilation Process
  35. 22 JavaFX Graphics and Multimedia
    1. Objectives
    2. Outline
    3. 22.1 Introduction
    4. 22.2 Controlling Fonts with Cascading Style Sheets (CSS)
      1. 22.2.1 CSS That Styles the GUI
        1. .vbox CSS Rule—Style Class Selectors
        2. #label1 CSS Rule—ID Selectors
        3. #label2 CSS Rule
        4. #label3 CSS Rule
        5. #label4 CSS Rule
        6. #label5 CSS Rule
        7. #label5 .text CSS Rule
      2. 22.2.2 FXML That Defines the GUI—Introduction to XML Markup2
        1. XML Declaration
        2. Attributes
        3. Comments
        4. FXML import Declarations
        5. Elements
        6. XML Namespaces
      3. 22.2.3 Referencing the CSS File from FXML
      4. 22.2.4 Specifying the VBox’s Style Class
      5. 22.2.5 Programmatically Loading CSS
    5. 22.3 Displaying Two-Dimensional Shapes
      1. 22.3.1 Defining Two-Dimensional Shapes with FXML
        1. Line Objects
        2. Rectangle Object
        3. Circle Object
        4. Ellipse Object
        5. Arc Object
      2. 22.3.2 CSS That Styles the Two-Dimensional Shapes
        1. Specifying Common Attributes for Various Objects
        2. Styling the Lines
        3. Styling the Rectangle
        4. Styling the Circle
        5. Styling the Ellipse
        6. Styling the Arc
    6. 22.4 Polylines, Polygons and Paths
      1. 22.4.1 GUI and CSS
      2. 22.4.2 PolyShapesController Class
        1. Method initialize
        2. Method drawingAreaMouseClicked
        3. Method shapeRadioButtonSelected
        4. Method displayShape
        5. Method clearButtonPressed
    7. 22.5 Transforms
    8. 22.6 Playing Video with Media, MediaPlayer and MediaViewer
      1. 22.6.1 VideoPlayer GUI
      2. 22.6.2 VideoPlayerController Class
        1. Instance Variables
        2. Creating a Media Object Representing the Video to Play
        3. Creating a MediaPlayer Object to Load the Video and Control Playback
        4. Attaching the MediaPlayer Object to the MediaView to Display the Video
        5. Configuring Event Handlers for MediaPlayer Events
        6. Binding the MediaViewer’s Size to the Scene’s Size
        7. Method playPauseButtonPressed
        8. Using Java SE 8 Lambdas to Implement the Runnables
    9. 22.7 Transition Animations
      1. 22.7.1 TransitionAnimations.fxml
      2. 22.7.2 TransitionAnimationsController Class
        1. FillTransition
        2. StrokeTransition
        3. ParallelTransition
        4. FadeTransition
        5. RotateTransition
        6. PathTransition
        7. ScaleTransition
        8. SequentialTransition
    10. 22.8 Timeline Animations
    11. 22.9 Frame-by-Frame Animation with AnimationTimer
    12. 22.10 Drawing on a Canvas
    13. 22.11 Three-Dimensional Shapes
    14. 22.12 Wrap-Up
    15. Summary
      1. Section 22.2 Controlling Fonts with Cascading Style Sheets (CSS)
      2. Section 22.2.1 CSS That Styles the GUI
      3. Section 22.2.2 FXML That Defines the GUI—Introduction to XML Markup
      4. Section 22.2.3 Referencing the CSS File from FXML
      5. Section 22.2.4 Specifying the VBox’s Style Class
      6. Section 22.2.5 Programmatically Loading CSS
      7. Section 22.3 Displaying Two-Dimensional Shapes
      8. Section 22.3.1 Defining Two-Dimensional Shapes with FXML
      9. Section 22.3.2 CSS That Styles the Two-Dimensional Shapes
      10. Section 22.4 Polylines, Polygons and Paths
      11. Section 22.4.2 PolyshapesController Class
      12. Section 22.5 Transforms
      13. Section 22.6 Playing Video with Media, MediaPlayer and MediaViewer
      14. Section 22.6.1 VideoPlayer GUI
      15. Section 22.6.2 VideoPlayerController Class
      16. Section 22.7 Transition Animations
      17. Section 22.7.2 TransitionAnimationsController Class
      18. Section 22.8 Timeline Animations
      19. Section 22.9 Frame-By-Frame Animation with AnimationTimer
      20. Section 22.10 Drawing on a Canvas
      21. Section 22.11 Three-Dimensional Shapes
    16. Self-Review Exercises
    17. Answers to Self-Review Exercises
    18. Exercises
      1. Project Exercises
  36. 23 Concurrency
    1. Objectives
    2. Outline
    3. 23.1 Introduction
    4. 23.2 Thread States and Life Cycle
      1. 23.2.1 New and Runnable States
      2. 23.2.2 Waiting State
      3. 23.2.3 Timed Waiting State
      4. 23.2.4 Blocked State
      5. 23.2.5 Terminated State
      6. 23.2.6 Operating-System View of the Runnable State
      7. 23.2.7 Thread Priorities and Thread Scheduling
      8. 23.2.8 Indefinite Postponement and Deadlock
    5. 23.3 Creating and Executing Threads with the Executor Framework
    6. 23.4 Thread Synchronization
      1. 23.4.1 Immutable Data
      2. 23.4.2 Monitors
      3. 23.4.3 Unsynchronized Mutable Data Sharing
        1. Class SimpleArray
        2. Class ArrayWriter
        3. Class SharedArrayTest
        4. ExecutorService Method awaitTermination
        5. Sample Program Output
      4. 23.4.4 Synchronized Mutable Data Sharing—Making Operations Atomic
        1. Class SimpleArray with Synchronization
    7. 23.5 Producer/Consumer Relationship without Synchronization
    8. 23.6 Producer/Consumer Relationship: ArrayBlockingQueue
    9. 23.7 (Advanced) Producer/Consumer Relationship with synchronized, wait, notify and notifyAll
    10. 23.8 (Advanced) Producer/Consumer Relationship: Bounded Buffers
    11. 23.9 (Advanced) Producer/Consumer Relationship: The Lock and Condition Interfaces
    12. 23.10 Concurrent Collections
    13. 23.11 Multithreading in JavaFX
      1. 23.11.1 Performing Computations in a Worker Thread: Fibonacci Numbers
        1. Creating a Task
        2. FibonacciNumbers GUI
        3. Class FibonacciNumbersController
        4. Method goButtonPressed
        5. Method nextNumberButtonPressed
      2. 23.11.2 Processing Intermediate Results: Sieve of Eratosthenes
        1. A Task to Find Prime Numbers
        2. Constructor
        3. Sieve of Eratosthenes
        4. Overridden Task Method call
        5. FindPrimes GUI
        6. Class FindPrimesController
        7. Method getPrimesButtonPressed
        8. Method cancelButtonPressed
    14. 23.12 sort/parallelSort Timings with the Java SE 8 Date/Time API
    15. 23.13 Java SE 8: Sequential vs. Parallel Streams
    16. 23.14 (Advanced) Interfaces Callable and Future
    17. 23.15 (Advanced) Fork/Join Framework
    18. 23.16 Wrap-Up
    19. Summary
      1. Section 23.1 Introduction
      2. Section 23.2 Thread States and Life Cycle
      3. Section 23.3 Creating and Executing Threads with the Executor Framework
      4. Section 23.4 Thread Synchronization
      5. Section 23.5 Producer/Consumer Relationship without Synchronization
      6. Section 23.6 Producer/Consumer Relationship: ArrayBlockingQueue
      7. Section 23.7 (Advanced) Producer/Consumer Relationship with synchronized, wait, notify and notifyAll
      8. Section 23.8 (Advanced) Producer/Consumer Relationship: Bounded Buffers
      9. Section 23.10 Concurrent Collections
      10. Section 23.11 Multithreading in JavaFX
      11. Section 23.11.1 Performing Computations in a Worker Thread: Fibonacci Numbers
      12. Section 23.11.2 Processing Intermediate Results: Sieve of Eratosthenes
      13. Section 23.12 sort/parallelSort Timings with the Java SE 8 Date/Time API
      14. Section 23.13 Java SE 8: Sequential vs. Parallel Streams
      15. Section 23.14 (Advanced) Interfaces Callable and Future
      16. Section 23.15 (Advanced) Fork/Join Framework
    20. Self-Review Exercises
    21. Exercises
    22. Exercises
      1. Parallel Streams
      2. Parallel Sorting and Searching Projects
  37. 24 Accessing Databases with JDBC
    1. Objectives
    2. Outline
    3. 24.1 Introduction
    4. 24.2 Relational Databases
    5. 24.3 A books Database
    6. 24.4 SQL
      1. 24.4.1 Basic SELECT Query
      2. 24.4.2 WHERE Clause
        1. Pattern Matching: Zero or More Characters
        2. Pattern Matching: Any Character
      3. 24.4.3 ORDER BY Clause
        1. Sorting in Descending Order
        2. Sorting By Multiple Columns
        3. Combining the WHERE and ORDER BY Clauses
      4. 24.4.4 Merging Data from Multiple Tables: INNER JOIN
      5. 24.4.5 INSERT Statement
      6. 24.4.6 UPDATE Statement
      7. 24.4.7 DELETE Statement
    7. 24.5 Setting Up a Java DB Database 1
      1. 24.5.1 Creating the Chapter’s Databases on Windows
      2. 24.5.2 Creating the Chapter’s Databases on macOS
      3. 24.5.3 Creating the Chapter’s Databases on Linux
    8. 24.6 Connecting to and Querying a Database
      1. 24.6.1 Automatic Driver Discovery
      2. 24.6.2 Connecting to the Database
      3. 24.6.3 Creating a Statement for Executing Queries
      4. 24.6.4 Executing a Query
      5. 24.6.5 Processing a Query’s ResultSet
    9. 24.7 Querying the books Database
      1. 24.7.1 ResultSetTableModel Class
        1. ResultSetTableModel Constructor
        2. ResultSetTableModel Method getColumnClass
        3. ResultSetTableModel Method getColumnCount
        4. ResultSetTableModel Method getColumnName
        5. ResultSetTableModel Method getRowCount
        6. ResultSetTableModel Method getValueAt
        7. ResultSetTableModel Method setQuery
        8. ResultSetTableModel Method disconnectFromDatabase
      2. 24.7.2 DisplayQueryResults App’s GUI
      3. 24.7.3 DisplayQueryResultsController Class
        1. static Fields
        2. Method initialize
        3. Method submitQueryButtonPressed
        4. Method applyFilterButtonPressed
        5. Method displayAlert
    10. 24.8 RowSet Interface
    11. 24.9 PreparedStatements
      1. 24.9.1 AddressBook App That Uses PreparedStatements
      2. 24.9.2 Class Person
      3. 24.9.3 Class PersonQueries
        1. Creating PreparedStatements
        2. PersonQueries Method getAllPeople
        3. PersonQueries Method getPeopleByLastName
        4. PersonQueries Methods addPerson and Close
      4. 24.9.4 AddressBook GUI
      5. 24.9.5 Class AddressBookController
        1. Instance Variables
        2. Method initialize
        3. Methods getAllEntries and selectFirstEntry
        4. Method displayContact
        5. Method addEntryButtonPressed
        6. Method findButtonPressed
        7. Method browseAllButtonPressed
    12. 24.10 Stored Procedures
    13. 24.11 Transaction Processing
    14. 24.12 Wrap-Up
    15. Summary
      1. Section 24.1 Introduction
      2. Section 24.2 Relational Databases
      3. Section 24.3 A books Database
      4. Section 24.4.1 Basic SELECT Query
      5. Section 24.4.2 WHERE Clause
      6. Section 24.4.3 ORDER BY Clause
      7. Section 24.4.4 Merging Data from Multiple Tables: INNER JOIN
      8. Section 24.4.5 INSERT Statement
      9. Section 24.4.6 UPDATE Statement
      10. Section 24.4.7 DELETE Statement
      11. Section 24.5 Setting Up a Java DB Database
      12. Section 24.6 Connecting to and Querying a Database
      13. Section 24.7 Querying the books Database
      14. Section 24.8 RowSet Interface
      15. Section 24.9 PreparedStatements
      16. Section 24.10 Stored Procedures
      17. Section 24.11 Transaction Processing
    16. Self-Review Exercises
    17. Answers to Self-Review Exercise
    18. Exercises
  38. 25 Introduction to JShell: Java 9’s REPL for Interactive Java
    1. Objectives
    2. Outline
    3. 25.1 Introduction
    4. 25.2 Installing JDK 9
    5. 25.3 Introduction to JShell
      1. 25.3.1 Starting a JShell Session
      2. 25.3.2 Executing Statements
      3. 25.3.3 Declaring Variables Explicitly
        1. Compilation Errors in JShell
        2. Fixing the Error
        3. Recalling and Re-executing a Previous Snippet
      4. 25.3.4 Listing and Executing Prior Snippets
        1. Executing Snippets By ID Number
      5. 25.3.5 Evaluating Expressions and Declaring Variables Implicitly
      6. 25.3.6 Using Implicitly Declared Variables
      7. 25.3.7 Viewing a Variable’s Value
      8. 25.3.8 Resetting a JShell Session
      9. 25.3.9 Writing Multiline Statements
      10. 25.3.10 Editing Code Snippets
        1. Editing a Single-Line Snippet
        2. Editing a Multiline Snippet
        3. Adding a New Snippet Via JShell Edit Pad
        4. Executing the New if Statement Again
      11. 25.3.11 Exiting JShell
    6. 25.4 Command-Line Input in JShell
    7. 25.5 Declaring and Using Classes
      1. 25.5.1 Creating a Class in JShell
        1. Viewing Declared Classes
      2. 25.5.2 Explicitly Declaring Reference-Type Variables
      3. 25.5.3 Creating Objects
        1. Declaring an Implicit Account Variable Initialized with an Account Object
        2. Viewing Declared Variables
      4. 25.5.4 Manipulating Objects
        1. Using the Return Value of a Method in a Statement
      5. 25.5.5 Creating a Meaningful Variable Name for an Expression
      6. 25.5.6 Saving and Opening Code-Snippet Files
        1. Saving Snippets to a File
        2. Loading Snippets from a File
        3. Using /open to Load Java Source-Code Files
    8. 25.6 Discovery with JShell Auto-Completion
      1. 25.6.1 Auto-Completing Identifiers
      2. 25.6.2 Auto-Completing JShell Commands
    9. 25.7 Exploring a Class’s Members and Viewing Documentation
      1. 25.7.1 Listing Class Math’s static Members
      2. 25.7.2 Viewing a Method’s Parameters
      3. 25.7.3 Viewing a Method’s Documentation
      4. 25.7.4 Viewing a public Field’s Documentation
      5. 25.7.5 Viewing a Class’s Documentation
      6. 25.7.6 Viewing Method Overloads
      7. 25.7.7 Exploring Members of a Specific Object
        1. Exploring toUpperCase
        2. Exploring substring
    10. 25.8 Declaring Methods
      1. 25.8.1 Forward Referencing an Undeclared Method—Declaring Method displayCubes
      2. 25.8.2 Declaring a Previously Undeclared Method
      3. 25.8.3 Testing cube and Replacing Its Declaration
      4. 25.8.4 Testing Updated Method cube and Method displayCubes
    11. 25.9 Exceptions
    12. 25.10 Importing Classes and Adding Packages to the CLASSPATH
    13. 25.11 Using an External Editor
    14. 25.12 Summary of JShell Commands
      1. 25.12.1 Getting Help in JShell
      2. 25.12.2 /edit Command: Additional Features
      3. 25.12.3 /reload Command
      4. 25.12.4 /drop Command
      5. 25.12.5 Feedback Modes
        1. Feedback Mode verbose
        2. Feedback Mode concise
        3. Feedback Mode silent
      6. 25.12.6 Other JShell Features Configurable with /set
        1. Customizing JShell Startup
    15. 25.13 Keyboard Shortcuts for Snippet Editing
    16. 25.14 How JShell Reinterprets Java for Interactive Use
    17. 25.15 IDE JShell Support
    18. 25.16 Wrap-Up
    19. Self-Review Exercises
    20. Answers to Self-Review Exercises
  39. Chapters on the Web
  40. A Operator Precedence Chart
  41. B ASCII Character Set
  42. C Keywords and Reserved Words
  43. D Primitive Types
    1. Notes
  44. E Using the Debugger
    1. Objectives
    2. Outline
    3. E.1 Introduction
    4. E.2 Breakpoints and the run, stop, cont and print Commands
    5. E.3 The print and set Commands
    6. E.4 Controlling Execution Using the step, step up and next Commands
    7. E.5 The watch Command
    8. E.6 The clear Command
    9. E.7 Wrap-Up
  45. Appendices on the Web
  46. 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
  47. ADDITIONAL COMMENTS FROM RECENT EDITIONS REVIEWERS
  48. 26 Swing GUI Components: Part 1
    1. Objectives
    2. Outline
    3. 26.1 Introduction
    4. 26.2 Java’s Nimbus Look-and-Feel
    5. 26.3 Simple GUI-Based Input/Output with JOptionPane
    6. 26.4 Overview of Swing Components
    7. 26.5 Displaying Text and Images in a Window
    8. 26.6 Text Fields and an Introduction to Event Handling with Nested Classes
    9. 26.7 Common GUI Event Types and Listener Interfaces
    10. 26.8 How Event Handling Works
    11. 26.9 JButton
    12. 26.10 Buttons That Maintain State
      1. 26.10.1 JCheckBox
        1. Relationship Between an Inner Class and Its Top-Level Class
      2. 26.10.2 JRadioButton
    13. 26.11 JComboBox; Using an Anonymous Inner Class for Event Handling
    14. 26.12 JList
    15. 26.13 Multiple-Selection Lists
    16. 26.14 Mouse Event Handling
    17. 26.15 Adapter Classes
    18. 26.16 JPanel Subclass for Drawing with the Mouse
    19. 26.17 Key Event Handling
    20. 26.18 Introduction to Layout Managers
      1. 26.18.1 FlowLayout
      2. 26.18.2 BorderLayout
      3. 26.18.3 GridLayout
    21. 26.19 Using Panels to Manage More Complex Layouts
    22. 26.20 JTextArea
    23. 26.21 Wrap-Up
    24. Summary
      1. Section 26.1 Introduction
      2. Section 26.2 Java’s Nimbus Look-and-Feel
      3. Section 26.3 Simple GUI-Based Input/Output with JOptionPane
      4. Section 26.4 Overview of Swing Components
      5. Section 26.5 Displaying Text and Images in a Window
      6. Section 26.6 Text Fields and an Introduction to Event Handling with Nested Classes
      7. Section 26.7 Common GUI Event Types and Listener Interfaces
      8. Section 26.8 How Event Handling Works
      9. Section 26.9 JButton
      10. Section 26.10 Buttons That Maintain State
      11. Section 26.11 JComboBox; Using an Anonymous Inner Class for Event Handling
      12. Section 26.12 JList
      13. Section 26.13 Multiple-Selection Lists
      14. Section 26.14 Mouse Event Handling
      15. Section 26.15 Adapter Classes
      16. Section 26.16 JPanel Subclass for Drawing with the Mouse
      17. Section 26.17 Key Event Handling
      18. Section 26.18 Introduction to Layout Managers
      19. Section 26.19 Using Panels to Manage More Complex Layouts
      20. Section 26.20 JTextArea
    25. Self-Review Exercises
    26. Answers to Self-Review Exercises
    27. Exercises
      1. (Optional) GUI and Graphics Case Study Exercise: Expanding the Interface
    28. Making a Difference
  49. 27 Graphics and Java 2D
    1. Objectives
    2. Outline
    3. 27.1 Introduction
    4. 27.2 Graphics Contexts and Graphics Objects
    5. 27.3 Color Control
    6. 27.4 Manipulating Fonts
    7. 27.5 Drawing Lines, Rectangles and Ovals
    8. 27.6 Drawing Arcs
    9. 27.7 Drawing Polygons and Polylines
    10. 27.8 Java 2D API
    11. 27.9 Wrap-Up
    12. Summary
      1. Section 27.1 Introduction
      2. Section 27.2 Graphics Contexts and Graphics Objects
      3. Section 27.3 Color Control
      4. Section 27.4 Manipulating Fonts
      5. Section 27.5 Drawing Lines, Rectangles and Ovals
      6. Section 27.6 Drawing Arcs
      7. Section 27.7 Drawing Polygons and Polylines
      8. Section 27.8 Java 2D API
    13. Self-Review Exercises
    14. Answers to Self-Review Exercises
    15. Exercises
      1. (Optional) GUI and Graphics Case Study Exercise: Adding Java 2D
      2. Making a Difference
  50. 28 Networking
    1. Objectives
    2. Outline
    3. 28.1 Introduction1
    4. 28.2 Reading a File on a Web Server
    5. 28.3 Establishing a Simple Server Using Stream Sockets
    6. 28.4 Establishing a Simple Client Using Stream Sockets
    7. 28.5 Client/Server Interaction with Stream Socket Connections
    8. 28.6 Datagrams: Connectionless Client/Server Interaction
    9. 28.7 Client/Server Tic-Tac-Toe Using a Multithreaded Server
    10. 28.8 Optional Online Case Study: DeitelMessenger2
    11. 28.9 Wrap-Up
    12. Summary
      1. Section 28.1 Introduction
      2. Section 28.2 Reading a File on a Web Server
      3. Section 28.3 Establishing a Simple Server Using Stream Sockets
      4. Section 28.4 Establishing a Simple Client Using Stream Sockets
      5. Section 28.6 Datagrams: Connectionless Client/Server Interaction
    13. Self-Review Exercises
    14. Answers to Self-Review Exercises
    15. Exercises
  51. 29 Java Persistence API (JPA)
    1. Objectives
    2. Outline
    3. 29.1 Introduction
    4. 29.2 JPA Technology Overview
      1. 29.2.1 Generated Entity Classes
      2. 29.2.2 Relationships Between Tables in the Entity Classes
      3. 29.2.3 The javax.persistence Package
        1. EntityManager Interface
        2. EntityManagerFactory Interface and the Persistence Class
        3. TypedQuery Class, Dynamic Queries and Named Queries
    5. 29.3 Querying a Database with JPA
      1. 29.3.1 Creating the Java DB Database
        1. Creating the Database
      2. 29.3.2 Populating the books Database with Sample Data
      3. 29.3.3 Creating the Java Project
      4. 29.3.4 Adding the JPA and Java DB Libraries
        1. EclipseLink—The JPA Reference Implementation
        2. Adding Libraries
      5. 29.3.5 Creating the Persistence Unit for the books Database
      6. 29.3.6 Querying the Authors Table
        1. Importing the JPA Interfaces and Class Used in This Example
        2. Creating the EntityManagerFactory Object
        3. Creating the EntityManager
        4. Creating a TypedQuery That Retrieves the Authors Table
        5. Displaying the Query Results
      7. 29.3.7 JPA Features of Autogenerated Class Authors
        1. JPA Annotations for Class Authors
        2. JPA Annotations for Class Authors’ Instance Variables
    6. 29.4 Named Queries; Accessing Data from Multiple Tables
      1. 29.4.1 Using a Named Query to Get the List of Authors, then Display the Authors with Their Titles
        1. Creating a TypedQuery That Retrieves the Authors Table
        2. Processing the Results
      2. 29.4.2 Using a Named Query to Get the List of Titles, then Display Each with Its Authors
    7. 29.5 Address Book: Using JPA and Transactions to Modify a Database
      1. 29.5.1 Transaction Processing
      2. 29.5.2 Creating the AddressBook Database, Project and Persistence Unit
        1. Step 1: Creating the addressbook Database
        2. Step 2: Populating the Database
        3. Step 3: Creating the AddressBook Project
        4. Step 4: Adding the JPA and Java DB Libraries
        5. Step 5: Creating the AddressBook Database’s Persistence Unit
      3. 29.5.3 Addresses Entity Class
        1. Ordering the Named Query Results
        2. ToString Method of Class Addresses
      4. 29.5.4 AddressBookController Class
        1. Obtaining the EntityManager
        2. Obtaining the Complete List of Contacts—Method getAllEntries
        3. Adding an Entry to the Database—Method addEntryButtonPressed
        4. Finding by Last Name—Method findButtonPressed
      5. 29.5.5 Other JPA Operations
        1. Updating an Existing Entity
        2. Deleting an Existing Entity
    8. 29.6 Web Resources
    9. 29.7 Wrap-Up
  52. 30 JavaServer™ Faces Web Apps: Part 1
    1. Objectives
    2. Outline
    3. 30.1 Introduction
    4. 30.2 HyperText Transfer Protocol (HTTP) Transactions
    5. 30.3 Multitier Application Architecture
    6. 30.4 Your First JSF Web App
      1. 30.4.1 The Default index.xhtml Document: Introducing Facelets
        1. Facelets: XHTML and JSF Markup
        2. XML Declaration, Comments and the DOCTYPE Declaration
        3. Specifying the XML Namespaces Used in the Document
        4. The h:head and h:body Elements
      2. 30.4.2 Examining the WebTimeBean Class
        1. JavaBeans
        2. Class WebTimeBean
        3. The @ManagedBean Annotation
        4. Processing the EL Expression
      3. 30.4.3 Building the WebTime JSF Web App in NetBeans
        1. Creating the JSF Web Application Project
        2. Examining the NetBeans Projects Window
        3. Examining the Default index.xhtml Page
        4. Editing the h:head Element’s Contents
        5. Editing the h:body Element’s Contents
        6. Defining the Page’s Logic: Class WebTimeBean
        7. Adding the EL Expression to the index.xhtml Page
        8. Running the Application
        9. Debugging the Application
        10. Testing the Application from Other Web Browsers
    7. 30.5 Model-View-Controller Architecture of JSF Apps
    8. 30.6 Common JSF Components
    9. 30.7 Validation Using JSF Standard Validators
    10. 30.8 Session Tracking
      1. 30.8.1 Cookies
      2. 30.8.2 Session Tracking with @SessionScoped Beans
        1. Test-Driving the App
        2. @SessionScoped Class SelectionsBean
        3. Methods of Class SelectionsBean
        4. index.xhtml
        5. recommendations.xhtml
        6. Iterating Through the List of Books
    11. 30.9 Wrap-Up
    12. Summary
      1. Section 30.1 Introduction
      2. Section 30.2 HyperText Transfer Protocol (HTTP) Transactions
      3. Section 30.3 Multitier Application Architecture
      4. Section 30.4 Your First JSF Web App
      5. Section 30.4.1 The Default index.xhtml Document: Introducing Facelets
      6. Section 30.4.2 Examining the WebTimeBean Class
      7. Section 30.5 Model-View-Controller Architecture of JSF Apps
      8. Section 30.6 Common JSF Components
      9. Section 30.7 Validation Using JSF Standard Validators
      10. Section 30.8 Session Tracking
      11. Section 30.8.1 Cookies
      12. Section 30.8.2 Session Tracking with @SessionScoped Beans
    13. Self-Review Exercises
    14. Answers to Self-Review Exercises
    15. Exercises
  53. 31 JavaServer™ Faces Web Apps: Part 2
    1. Objectives
    2. Outline
    3. 31.1 Introduction
    4. 31.2 Accessing Databases in Web Apps
      1. 31.2.1 Setting Up the Database
        1. Open NetBeans and Ensure that Java DB and GlassFish Are Running
        2. Creating the Database
        3. Populate the addressbook Database with Sample Data
      2. 31.2.2 Class AddressBean
        1. Defining a Data Source with the Annotation @DataSourceDefinition
        2. Class AddressBean’s Annotations—@Named and @javax.faces.view.ViewScoped
        3. Injecting the DataSource into Class AddressBean
        4. AddressBean Method getAddresses
        5. AddressBean Method save
      3. 31.2.3 index.xhtml Facelets Page
        1. The h:dataTable Element
        2. The h:column Elements
      4. 31.2.4 addentry.xhtml Facelets Page
    5. 31.3 Ajax
    6. 31.4 Adding Ajax Functionality to the Validation App
    7. 31.5 Wrap-Up
    8. Summary
      1. Section 30.2.2 Class AddressBean
      2. Section 30.2.3 index.xhtml Facelets Page
      3. Section 30.2.4 addentry.xhtml Facelets Page
      4. Section 31.3 Ajax
      5. Section 31.4 Adding Ajax Functionality to the Validation App
    9. Self-Review Exercise
    10. Answers to Self-Review Exercise
    11. Exercises
  54. 32 REST Web Services
    1. Objectives
    2. Outline
    3. 32.1 Introduction
    4. 32.2 Web Service Basics
    5. 32.3 Simple Object Access Protocol (SOAP)
    6. 32.4 Representational State Transfer (REST)
    7. 32.5 JavaScript Object Notation (JSON)
    8. 32.6 Publishing and Consuming SOAP-Based Web Services
      1. 32.6.1 Creating a Web Application Project and Adding a Web Service Class in NetBeans
      2. Creating a Web Application Project in NetBeans
      3. Adding a Web Service Class to a Web Application Project
      4. 32.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
      5. 32.6.3 Publishing the WelcomeSOAP Web Service from NetBeans
      6. 32.6.4 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
      7. 32.6.5 Describing a Web Service with the Web Service Description Language (WSDL)
        1. Accessing the WelcomeSOAP Web Service’s WSDL from Another Computer
      8. 32.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
      9. 32.6.7 Consuming the WelcomeSOAP Web Service
    9. 32.7 Publishing and Consuming REST-Based XML Web Services
      1. 32.7.1 Creating a REST-Based XML Web Service
        1. Testing the RESTful Web Service
        2. WADL
      2. 32.7.2 Consuming a REST-Based XML Web Service
    10. 32.8 Publishing and Consuming REST-Based JSON Web Services
      1. 32.8.1 Creating a REST-Based JSON Web Service
      2. 32.8.2 Consuming a REST-Based JSON Web Service
    11. 32.9 Session Tracking in a SOAP Web Service
      1. 32.9.1 Creating a Blackjack Web Service
        1. Session Tracking in Web Services: @HttpSessionScope Annotation
        2. Client Interactions with the Blackjack Web Service
      2. 32.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. 32.10 Consuming a Database-Driven SOAP Web Service
      1. 32.10.1 Creating the Reservation Database
        1. Creating the Reservation Web Service
      2. 32.10.2 Creating a Web Application to Interact with the Reservation Service
        1. index.xhtml
        2. ReservationBean.java
    13. 32.11 Equation Generator: Returning User-Defined Types
      1. 32.11.1 Creating the EquationGeneratorXML Web Service
      2. 32.11.2 Consuming the EquationGeneratorXML Web Service
      3. 32.11.3 Creating the EquationGeneratorJSON Web Service
      4. 32.11.4 Consuming the EquationGeneratorJSON Web Service
    14. 32.12 Wrap-Up
    15. Summary
      1. Section 32.1 Introduction
      2. Section 32.2 Web Service Basics
      3. Section 32.3 Simple Object Access Protocol (SOAP)
      4. Section 32.4 Representational State Transfer (REST)
      5. Section 32.5 JavaScript Object Notation (JSON)
      6. Section 32.6.1 Creating a Web Application Project and Adding a Web Service Class in NetBeans
      7. Section 31.6.2 Defining the WelcomeSOAP Web Service in NetBeans
      8. Section 31.6.3 Publishing the WelcomeSOAP Web Service from NetBeans
      9. Section 31.6.4 Testing the WelcomeSOAP Web Service with GlassFish Application Server’s Tester Web Page
      10. Section 32.6.5 Describing a Web Service with the Web Service Description Language (WSDL)
      11. Section 31.6.6 Creating a Client to Consume the WelcomeSOAP Web Service
      12. Section 31.6.7 Consuming the WelcomeSOAP Web Service
      13. Section 32.7.1 Creating a REST-Based XML Web Service
      14. Section 32.7.2 Consuming a REST-Based XML Web Service
      15. Section 32.8 Publishing and Consuming REST-Based JSON Web Services
      16. Section 32.8.1 Creating a REST-Based JSON Web Service
      17. Section 32.8.2 Consuming a REST-Based JSON Web Service
      18. Section 32.9 Session Tracking in a SOAP Web Service
      19. Section 31.9.1 Creating a Blackjack Web Service
      20. Section 31.9.2 Consuming the Blackjack Web Service
      21. Section 32.11 Equation Generator: Returning User-Defined Types
    16. Self-Review Exercises
    17. Answers to Self-Review Exercises
    18. Exercises
    19. Making a Difference
  55. 33 ATM Case Study, Part 1: Object-Oriented Design with the UML
    1. Objectives
    2. Outline
    3. 33.1 Case Study Introduction
    4. 33.2 Examining the Requirements Document
      1. Self-Review Exercises for Section 33.2
    5. 33.3 Identifying the Classes in a Requirements Document
      1. Self-Review Exercises for Section 33.3
    6. 33.4 Identifying Class Attributes
      1. Self-Review Exercises for Section 33.4
    7. 33.5 Identifying Objects’ States and Activities
      1. Self-Review Exercises for Section 33.5
    8. 33.6 Identifying Class Operations
      1. Self-Review Exercises for Section 33.6
    9. 33.7 Indicating Collaboration Among Objects
      1. Self-Review Exercises for Section 33.7
    10. 33.8 Wrap-Up
    11. Answers to Self-Review Exercises
  56. 34 ATM Case Study Part 2: Implementing the Design
    1. Objectives
    2. Outline
    3. 34.1 Introduction
    4. 34.2 Starting to Program the Classes of the ATM System
      1. Self-Review Exercises for Section 34.2
    5. 34.3 Incorporating Inheritance and Polymorphism into the ATM System
      1. Self-Review Exercises for Section 34.3
    6. 34.4 ATM Case Study Implementation
      1. 34.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. 34.4.2 Class Screen
      3. 34.4.3 Class Keypad
      4. 34.4.4 Class CashDispenser
      5. 34.4.5 Class DepositSlot
      6. 34.4.6 Class Account
      7. 34.4.7 Class BankDatabase
      8. 34.4.8 Class Transaction
      9. 34.4.9 Class BalanceInquiry
      10. 34.4.10 Class Withdrawal
      11. 34.4.11 Class Deposit
      12. 34.4.12 Class ATMCaseStudy
    7. 34.5 Wrap-Up
    8. Answers to Self-Review Exercises
  57. 35 Swing GUI Components: Part 2
    1. Objectives
    2. Outline
    3. 35.1 Introduction
      1. Java SE 8: Implementing Event Listeners with Lambdas
    4. 35.2 JSlider
    5. 35.3 Understanding Windows in Java
      1. Returning Window Resources to the System
      2. Displaying and Positioning Windows
      3. Window Events
    6. 35.4 Using Menus with Frames
      1. Overview of Several Menu-Related Components
      2. Using Menus in an Application
      3. Setting Up the File Menu
      4. Setting Up the Format Menu
      5. Creating the Rest of the GUI and Defining the Event Handlers
    7. 35.5 JPopupMenu
    8. 35.6 Pluggable Look-and-Feel
    9. 35.7 JDesktopPane and JInternalFrame
    10. 35.8 JTabbedPane
    11. 35.9 BoxLayout Layout Manager
      1. Creating Box Containers
      2. Struts
      3. Glue
      4. Rigid Areas
      5. Setting a BoxLayout for a Container
      6. Adding Glue and JButtons
      7. Creating the JTabbedPane
      8. Attaching the Box Containers and JPanel to the JTabbedPane
    12. 35.10 GridBagLayout Layout Manager
      1. GridBagConstraints fields.
      2. GridBagConstraints Field anchor
      3. GridBagConstraints Field fill
      4. GridBagConstraints Fields gridx and gridy
      5. GridBagConstraints Field gridwidth
      6. GridBagConstraints Field weightx
      7. GridBagConstraints Field weighty
      8. Effects of weightx and weighty
      9. Demonstrating GridBagLayout
      10. GUI Overview
      11. JTextArea textArea1
      12. JButton button1
      13. JComboBox comboBox
      14. JButton button2
      15. JButton button3
      16. JTextField textField and JTextArea textArea2
      17. Method addComponent
      18. GridBagConstraints Constants RELATIVE and REMAINDER
      19. Setting the JFrame’s Layout to a GridBagLayout
      20. Configuring the JTextField
      21. Configuring JButton buttons[0]
      22. Configuring JButton buttons[1]
      23. Configuring JButton buttons[2]
      24. Configuring JComboBox
      25. Configuring JButton buttons[3]
      26. Configuring JButton buttons[4]
      27. Configuring JList
    13. 35.11 Wrap-Up
    14. Summary
      1. Section 22.2 JSlider
      2. Section 35.3 Understanding Windows in Java
      3. Section 35.4 Using Menus with Frames
      4. Section 22.5 JPopupMenu
      5. Section 35.6 Pluggable Look-and-Feel
      6. Section 22.7 JDesktopPane and JInternalFrame
      7. Section 22.8 JTabbedPane
      8. Section 22.9 BoxLayout Layout Manager
      9. Section 22.10 GridBagLayout Layout Manager
    15. Self-Review Exercises
    16. Answers to Self-Review Exercises
    17. Exercises
  58. 36 Java Platform Module System
    1. Objectives
    2. Outline
    3. 36.1 Introduction1
    4. 36.2 Module Declarations
      1. 36.2.1 requires
      2. 36.2.2 requires transitive—Implied Readability
      3. 36.2.3 exports and exports…to
      4. 36.2.4 uses
      5. 36.2.5 provides…with
      6. 36.2.6 open, opens and opens…to10,11
        1. Allowing Runtime-Only Access to a Package
        2. Allowing Runtime-Only Access to a Package By Specific Modules
        3. Allowing Runtime-Only Access to All Packages in a Module
        4. Reflection Defaults
        5. Dependency Injection
      7. 36.2.7 Restricted Keywords
    5. 36.3 Modularized Welcome App
      1. 36.3.1 Welcome App’s Structure
        1. Module Naming Conventions
        2. Listing the java.base Module’s Contents
      2. 36.3.2 Class Welcome
      3. 36.3.3 module-info.java
      4. 36.3.4 Module-Dependency Graph
      5. 36.3.5 Compiling a Module
        1. Note Regarding Lengthy Commands in This Chapter
        2. Welcome App’s Folder Structure After Compilation
        3. Listing the com.deitel.welcome Module’s Contents
      6. 36.3.6 Running an App from a Module’s Exploded Folders
      7. 36.3.7 Packaging a Module into a Modular JAR File
      8. 36.3.8 Running the Welcome App from a Modular JAR File
      9. 36.3.9 Aside: Classpath vs. Module Path
    6. 36.4 Creating and Using a Custom Module
      1. 36.4.1 Exporting a Package for Use in Other Modules
        1. com.deitel.timelibrary Module Declaration
      2. 36.4.2 Using a Class from a Package in Another Module
        1. com.deitel.timetest Module Declaration
        2. com.deitel.timetest Module-dependency Graph
      3. 36.4.3 Compiling and Running the Example
        1. Compiling Module com.deitel.timelibrary
        2. Compiling Module com.deitel.timetest
        3. Running the Example
      4. 36.4.4 Packaging the App into Modular JAR Files
        1. Running the App from a Modular JAR File
      5. 36.4.5 Strong Encapsulation and Accessibility
        1. Compilation Error When Attempting to Use an Inaccessible Type
    7. 36.5 Module-Dependency Graphs: A Deeper Look
      1. 36.5.1 java.sql
      2. 36.5.2 java.se
      3. 36.5.3 Browsing the JDK Module Graph
      4. 36.5.4 Error: Module Graph with a Cycle
        1. A Module That (Incorrectly) Requires Itself
        2. Two Modules That (Incorrectly) Require One Another
        3. Modules in a Cycle Are Really “One Thing”
    8. 36.6 Migrating Code to Java 9
      1. 36.6.1 Unnamed Module
      2. 36.6.2 Automatic Modules
      3. 36.6.3 jdeps: Java Dependency Analysis
        1. Determining the Modules You Need
        2. Verbose jdeps Output
        3. Using jdeps to Produce DOT Files for Graphing Tools
        4. Additional jdeps Options
    9. 36.7 Resources in Modules; Using an Automatic Module
      1. 36.7.1 Automatic Modules
        1. Code Changes for Modularization
      2. 36.7.2 Requiring Multiple Modules
      3. 36.7.3 Opening a Module for Reflection
      4. 36.7.4 Module-Dependency Graph
      5. 36.7.5 Compiling the Module
        1. Copying the Resource Files into the Module
      6. 36.7.6 Running a Modularized App
    10. 36.8 Creating Custom Runtimes with jlink
      1. 36.8.1 Listing the JRE’s Modules
      2. 36.8.2 Custom Runtime Containing Only java.base
        1. Note Regarding the JAVA_HOME Variable
        2. Executing the Welcome App Using This Custom Runtime
        3. Listing the Modules in a Custom Runtime
      3. 36.8.3 Creating a Custom Runtime for the Welcome App
      4. 36.8.4 Executing the Welcome App Using a Custom Runtime
      5. 36.8.5 Using the Module Resolver on a Custom Runtime
    11. 36.9 Services and ServiceLoader
      1. 36.9.1 Service-Provider Interface
      2. 36.9.2 Loading and Consuming Service Providers
        1. Using ServiceLoader to Locate Service Providers
        2. Using a Service-Provider Interface
      3. 36.9.3 uses Module Directive and Service Consumers
      4. 36.9.4 Running the App with No Service Providers
      5. 36.9.5 Implementing a Service Provider
      6. 36.9.6 provides…with Module Directive and Declaring a Service Provider
      7. 36.9.7 Running the App with One Service Provider
      8. 36.9.8 Implementing a Second Service Provider
      9. 36.9.9 Running the App with Two Service Providers
    12. 36.10 Wrap-Up
  59. 37 Additional Java 9 Topics
    1. Objectives
    2. Outline
    3. 37.1 Introduction
    4. 37.2 Recap: Java 9 Features Covered in Earlier Chapters
    5. 37.3 New Version String Format
    6. 37.4 Regular Expressions: New Matcher Class Methods
      1. 37.4.1 Methods appendReplacement and appendTail
      2. 37.4.2 Methods replaceFirst and replaceAll
      3. 37.4.3 Method results
    7. 37.5 New Stream Interface Methods
      1. 37.5.1 Stream Methods takeWhile and dropWhile
      2. 37.5.2 Stream Method iterate
      3. 37.5.3 Stream Method ofNullable
    8. 37.6 Modules in JShell
      1. Adding a Module to the JShell Session
      2. Importing a Class from a Module’s Exported Package(s)
      3. Using the Imported Class
    9. 37.7 JavaFX 9 Skin APIs
    10. 37.8 Other GUI and Graphics Enhancements
      1. 37.8.1 Multi-Resolution Images
      2. 37.8.2 TIFF Image I/O
      3. 37.8.3 Platform-Specific Desktop Features
    11. 37.9 Security Related Java 9 Topics
      1. 37.9.1 Filter Incoming Serialization Data
      2. 37.9.2 Create PKCS12 Keystores by Default
      3. 37.9.3 Datagram Transport Layer Security (DTLS)
      4. 37.9.4 OCSP Stapling for TLS
      5. 37.9.5 TLS Application-Layer Protocol Negotiation Extension
    12. 37.10 Other Java 9 Topics
      1. 37.10.1 Indify String Concatenation
      2. 37.10.2 Platform Logging API and Service
      3. 37.10.3 Process API Updates
      4. 37.10.4 Spin-Wait Hints
      5. 37.10.5 UTF-8 Property Resource Bundles
      6. 37.10.6 Use CLDR Locale Data by Default
      7. 37.10.7 Elide Deprecation Warnings on Import Statements
      8. 37.10.8 Multi-Release JAR Files
      9. 37.10.9 Unicode 8
      10. 37.10.10 Concurrency Enhancements
        1. New Methods of Class CompletableFuture
    13. 37.11 Items Removed from the JDK and Java 9
      1. Removed Platform Features
      2. Removed Methods
    14. 37.12 Items Proposed for Removal from Future Java Versions
      1. 37.12.1 Enhanced Deprecation
      2. 37.12.2 Items Likely to Be Removed in Future Java Versions
      3. 37.12.3 Finding Deprecated Features
      4. 37.12.4 Java Applets
    15. 37.13 Wrap-Up
  60. F Using the Java API Documentation
    1. F.1 Introduction
    2. F.2 Navigating the Java API
  61. G Creating Documentation with javadoc
    1. G.1 Introduction
    2. G.2 Documentation Comments
    3. G.3 Documenting Java Source Code
    4. G.4 javadoc
      1. Downloading the Java Documentation
      2. Executing javadoc from the Command Line
    5. G.5 Files Produced by javadoc
  62. H Unicode®
    1. H.1 Introduction
    2. H.2 Unicode Transformation Formats
    3. H.3 Characters and Glyphs
    4. H.4 Advantages/Disadvantages of Unicode
    5. H.5 Using Unicode
    6. H.6 Character Ranges
  63. I Formatted Output
    1. Objectives
    2. Outline
    3. I.1 Introduction
    4. I.2 Streams
    5. I.3 Formatting Output with printf
    6. I.4 Printing Integers
    7. I.5 Printing Floating-Point Numbers
    8. I.6 Printing Strings and Characters
    9. I.7 Printing Dates and Times
    10. I.8 Other Conversion Characters
    11. I.9 Printing with Field Widths and Precisions
    12. I.10 Using Flags in the printf Format String
    13. I.11 Printing with Argument Indices
    14. I.12 Printing Literals and Escape Sequences
    15. I.13 Formatting Output with Class Formatter
    16. I.14 Wrap-Up
  64. J Number Systems
    1. Objectives
    2. Outline
    3. J.1 Introduction
    4. J.2 Abbreviating Binary Numbers as Octal and Hexadecimal Numbers
    5. J.3 Converting Octal and Hexadecimal Numbers to Binary Numbers
    6. J.4 Converting from Binary, Octal or Hexadecimal to Decimal
    7. J.5 Converting from Decimal to Binary, Octal or Hexadecimal
    8. J.6 Negative Binary Numbers: Two’s Complement Notation
  65. K Bit Manipulation
    1. K.1 Introduction
    2. K.2 Bit Manipulation and the Bitwise Operators
    3. K.3 BitSet Class
  66. L Labeled break and continue Statements
    1. L.1 Introduction
    2. L.2 Labeled break Statement
    3. L.3 Labeled continue Statement
  67. M UML 2: Additional Diagram Types
    1. M.1 Introduction
    2. M.2 Additional Diagram Types
  68. N Design Patterns
    1. N.1 Introduction
      1. History of Object-Oriented Design Patterns
    2. N.2 Creational, Structural and Behavioral Design Patterns
      1. N.2.1 Creational Design Patterns
        1. Singleton
      2. N.2.2 Structural Design Patterns
        1. Proxy
      3. N.2.3 Behavioral Design Patterns
        1. Memento
        2. State
      4. N.2.4 Conclusion
    3. N.3 Design Patterns in Packages java.awt and javax.swing
      1. N.3.1 Creational Design Patterns
        1. Factory Method
      2. N.3.2 Structural Design Patterns
        1. Adapter
        2. Bridge
        3. Composite
      3. N.3.3 Behavioral Design Patterns
        1. Chain of Responsibility
        2. Command
        3. Observer
        4. Strategy
        5. Template Method
      4. N.3.4 Conclusion
    4. N.4 Concurrency Design Patterns
      1. Concurrency Design Patterns
    5. N.5 Design Patterns Used in Packages java.io and java.net
      1. N.5.1 Creational Design Patterns
        1. Abstract Factory
      2. N.5.2 Structural Design Patterns
        1. Decorator
        2. Facade
      3. N.5.3 Architectural Patterns
        1. MVC
        2. Layers
      4. N.5.4 Conclusion
    6. N.6 Design Patterns Used in Package java.util
      1. N.6.1 Creational Design Patterns
        1. Prototype
      2. N.6.2 Behavioral Design Patterns
        1. Iterator
    7. N.7 Wrap-Up

Product information

  • Title: Java How to Program, Early Objects, 11th Edition
  • Author(s): Paul J. Deitel, Harvey Deitel
  • Release date: June 2017
  • Publisher(s): Pearson
  • ISBN: 9780134751962