O'Reilly logo

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

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

Start Free Trial

No credit card required

Java How to Program, Early Objects, Eleventh 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’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 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 Windows—A Proprietary Operating System
      2. 1.6.2 Linux—An Open-Source Operating System Linux—An Open-Source Operating System
      3. 1.6.3 Apple’s macOS and Apple’s iOS for iPhone Apple’s macOS and Apple’s iOS for iPhone®, iPad® and iPod Touch® Devices
      4. 1.6.4 Google’s Android 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 ’s getName Method
        5. null—the Default Initial Value for —the Default Initial Value for String Variables
        6. Calling Class Account’s ’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 ’s Constructor and Method setName
      2. 3.3.2 Class AccountTest: Initializing Account Objects When They’re Created 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’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 ’s Methods Can All Use balance
      2. 3.4.2 AccountTest Class to Use Class Account
        1. Displaying the Account Objects’ Initial Balances 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 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’s Alignment
        2. Specifying the VBox’s Preferred Size’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’s Text
        3. Changing the Label’s Font’s Font
      9. 3.6.9 Adding and Configuring an ImageView
        1. Adding an ImageView to the VBox
        2. Setting the ImageView’s Image’s Image
        3. Changing the ImageView’s Size’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 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’s Text
        5. Adding and Configuring a Canvas
        6. Setting the Canvas’s Width and Height’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’s Instance Variable Name
        3. Specifying the Button’s Event-Handler Method’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’s Coordinate System
        4. Drawing Lines
      5. 4.15.5 Class DrawLines—The Main Application Class—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 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 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’s Methods and Instance Variables
        2. Class CommissionEmployee’s Constructor’s Constructor
        3. Class CommissionEmployee’s ’s earnings Method
        4. Class CommissionEmployee’s ’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 ’s earnings Method
        4. Class BasePlusCommissionEmployee’s ’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’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 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’s Alignment
        2. Specifying the VBox’s Preferred Size’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’s Text
        3. Changing the Label’s Font’s Font
      6. 12.4.6 Adding and Configuring an ImageView
        1. Adding an ImageView to the VBox
        2. Setting the ImageView’s Image’s Image
        3. Changing the ImageView’s Size’s Size
      7. 12.4.7 Previewing the Welcome GUI
    7. 12.5 Tip Calculator App—Introduction to Event Handling 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 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 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’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’s Properties
        14. Previewing the Final Layout
        15. Specifying the Controller Class’s Name
        16. Specifying the Calculate Button’s Event-Handler Method Name’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 ’s import Statements
        2. TipCalculatorController’s ’s static Variables and Instance Variables
        3. @FXML Annotation
        4. TipCalculatorController’s ’s calculateButtonPressed Event Handler
        5. Registering the Calculate Button’s Event Handler
        6. Calculating and Displaying the Tip and Total Amounts
        7. TipCalculatorController’s ’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 Welcome App—Displaying Text and an Image
      5. Section 12.5.2 Technologies Overview
      6. Section 12.5.3 Building the App’s GUI 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 Heights’ 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 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’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 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 CSS Rule—Style Class Selectors
        2. #label1 CSS Rule—ID Selectors 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 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’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’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 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’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 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 Creating the Chapter’s Databases on Windows
      2. 24.5.2 Creating the Chapter’s Databases on macOS Creating the Chapter’s Databases on macOS
      3. 24.5.3 Creating the Chapter’s Databases on Linux 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 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 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 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 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 Exploring a Class’s Members and Viewing Documentation
      1. 25.7.1 Listing Class Math’s ’s static Members
      2. 25.7.2 Viewing a Method’s Parameters Viewing a Method’s Parameters
      3. 25.7.3 Viewing a Method’s Documentation Viewing a Method’s Documentation
      4. 25.7.4 Viewing a public Field’s Documentation Field’s Documentation
      5. 25.7.5 Viewing a Class’s Documentation 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 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