Java™ How To Program (Early Objects), Tenth Edition

Book description

Java How to Program (Early Objects), Tenth Editionis intended for use in the Java programming course. It also serves as a useful reference and self-study tutorial to Java programming.

The Deitels’ groundbreaking How to Program series offers unparalleled breadth and depth of object-oriented programming concepts and intermediate-level topics for further study. Java How to Program (Early Objects), Tenth Edition, teaches programming by presenting the concepts in the context of full working programs and takes an early-objects approach
 

MyProgrammingLab forJava How to Program (Early Objects) is a total learning package. MyProgrammingLab is an online homework, tutorial, and assessment program that truly engages students in learning. It helps students better prepare for class, quizzes, and exams—resulting in better performance in the course—and provides educators a dynamic set of tools for gauging individual and class progress.

Teaching and Learning Experience

This program presents a better teaching and learning experience—for you and your students.

  • Personalize Learning with MyProgrammingLab: Through the power of practice and immediate personalized feedback, MyProgrammingLab helps students fully grasp the logic, semantics, and syntax of programming.

  • Teach Programming with the Deitels’ Signature Live Code Approach: Java language features are introduced with thousands of lines of code in hundreds of complete working programs.

  • Introduce Objects Early: Presenting objects and classes early gets students “thinking about objects” immediately and mastering these concepts more thoroughly.

  • Keep Your Course Current: This edition can be used with Java SE 7 or Java SE 8, and is up-to-date with the latest technologies and advancements.

  • Facilitate Learning with Outstanding Applied Pedagogy: Making a Difference exercise sets, projects, and hundreds of valuable programming tips help students apply concepts.

  • Support Instructors and Students: Student and instructor resources are available to expand on the topics presented in the text.

  • Note: ISBN-10: 0133813436 / ISBN-13: 9780133813432 Java How to Program, Early Objects Plus MyProgrammingLab with Pearson eText -- Access Card Package, 10/e. This package consists of:

  • ISBN-10: 0133807800 / ISBN-13: 9780133807806 Java How to Program, Early Objects, 10/e

  • ISBN-10: 0133811905 / ISBN-13: 9780133811902 MyProgrammingLab with Pearson eText -- Access Card -- for Java How to Program, Early Objects

  • ALERT: Before you purchase, check with your instructor or review your course syllabus to ensure that you select the correct ISBN. Several versions of Pearson's MyLab & Mastering products exist for each title, including customized versions for individual schools, and registrations are not transferable. In addition, you may need a CourseID, provided by your instructor, to register for and use Pearson's MyLab & Mastering products.

    Packages

    Access codes for Pearson's MyLab & Mastering products may not be included when purchasing or renting from companies other than Pearson; check with the seller before completing your purchase.

    Used or rental books

    If you rent or purchase a used book with an access code, the access code may have been redeemed previously and you may have to purchase a new access code.

    Access codes

    Access codes that are purchased from sellers other than Pearson carry a higher risk of being either the wrong ISBN or a previously redeemed code. Check with the seller prior to purchase.

    Table of contents

    1. About This eBook
    2. Title Page
    3. Copyright Page
    4. Deitel® Series Page
      1. How To Program Series
      2. Simply Series
      3. CourseSmart Web Books
      4. Deitel® Developer Series
      5. LiveLessons Video Learning Products
    5. Dedication Page
    6. Contents
    7. Foreword
    8. Preface
      1. Keeping in Touch with the Authors
      2. Source Code and VideoNotes
      3. Modular Organization
        1. Introduction
        2. Additional Programming Fundamentals
        3. Object-Oriented Programming and Object-Oriented Design
        4. Swing Graphical User Interfaces and Java 2D Graphics
        5. Data Structures, Collections, Lambdas and Streams
        6. Concurrency; Networking
        7. JavaFX Graphical User Interfaces, Graphics and Multimedia
        8. Database-Driven Desktop and Web Development
      4. New and Updated Features
        1. Java Standard Edition: Java SE 7 and the New Java SE 8
        2. Swing and JavaFX GUI, Graphics and Multimedia
        3. Concurrency
        4. Getting Monetary Amounts Right
        5. Object Technology
        6. Data Structures and Generic Collections
        7. Database
        8. Web Application Development
      5. Secure Java Programming
      6. Optional GUI and Graphics Case Study
      7. Teaching Approach
      8. Software Used in Java How to Program, 10/e
      9. Instructor Supplements
      10. Acknowledgments
        1. Reviewers
      11. A Special Thank You to Brian Goetz
      12. About the Authors
      13. About Deitel® & Associates, Inc.
    9. Before You Begin
      1. Font and Naming Conventions
      2. Software Used in the Book
        1. Java Standard Edition Development Kit 7 (JDK 7)
        2. Java Standard Edition Development Kit (JDK) 8
      3. JDK Installation Instructions
      4. Setting the PATH Environment Variable
        1. JDK Installation Directory and the bin Subdirectory
      5. Setting the CLASSPATH Environment Variable
      6. Setting the JAVA_HOME Environment Variable
      7. Java Integrated Development Environments (IDEs)
        1. NetBeans Downloads
        2. Eclipse Downloads
        3. IntelliJ IDEA Community Edition Downloads
      8. Obtaining the Code Examples
      9. Java’s Nimbus Look-and-Feel
    10. 1. Introduction to Computers, the Internet and Java
      1. 1.1 Introduction
        1. Java Standard Edition
        2. Java Enterprise Edition
        3. Java Micro Edition
      2. 1.2 Hardware and Software
        1. 1.2.1 Moore’s Law
        2. 1.2.2 Computer Organization
      3. 1.3 Data Hierarchy
        1. Bits
        2. Characters
        3. Fields
        4. Records
        5. Files
        6. Database
        7. Big Data
      4. 1.4 Machine Languages, Assembly Languages and High-Level Languages
        1. Machine Languages
        2. Assembly Languages and Assemblers
        3. High-Level Languages and Compilers
        4. Interpreters
      5. 1.5 Introduction to Object Technology
        1. 1.5.1 The 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)
      6. 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 Android
      7. 1.7 Programming Languages
      8. 1.8 Java
        1. Java Class Libraries
      9. 1.9 A Typical Java Development Environment
        1. Phase 1: Creating a Program
        2. Phase 2: Compiling a Java Program into Bytecodes
        3. Phase 3: Loading a Program into Memory
        4. Phase 4: Bytecode Verification
        5. Phase 5: Execution
        6. Problems That May Occur at Execution Time
      10. 1.10 Test-Driving a Java Application
      11. 1.11 Internet and World Wide Web
        1. 1.11.1 The Internet: A Network of Networks
        2. 1.11.2 The World Wide Web: Making the Internet User-Friendly
        3. 1.11.3 Web Services and Mashups
        4. 1.11.4 Ajax
        5. 1.11.5 The Internet of Things
      12. 1.12 Software Technologies
      13. 1.13 Keeping Up-to-Date with Information Technologies
      14. Self-Review Exercises
      15. Answers to Self-Review Exercises
      16. Exercises
      17. Making a Difference
    11. 2. Introduction to Java Applications; Input/Output and Operators
      1. 2.1 Introduction
      2. 2.2 Your First Program in Java: Printing a Line of Text
        1. Commenting Your Programs
        2. Using Blank Lines
        3. Declaring a Class
        4. Filename for a public Class
        5. Class Names and Identifiers
        6. Class Body
        7. Declaring a Method
        8. Performing Output with System.out.println
        9. Using End-of-Line Comments on Right Braces for Readability
        10. Compiling Your First Java Application
        11. Executing the Welcome1 Application
      3. 2.3 Modifying Your First Java Program
        1. Displaying a Single Line of Text with Multiple Statements
        2. Displaying Multiple Lines of Text with a Single Statement
      4. 2.4 Displaying Text with printf
      5. 2.5 Another Application: Adding Integers
        1. 2.5.1 import Declarations
        2. 2.5.2 Declaring Class Addition
        3. 2.5.3 Declaring and Creating a Scanner to Obtain User Input from the Keyboard
        4. 2.5.4 Declaring Variables to Store Integers
        5. 2.5.5 Prompting the User for Input
        6. 2.5.6 Obtaining an int as Input from the User
        7. 2.5.7 Prompting for and Inputting a Second int
        8. 2.5.8 Using Variables in a Calculation
        9. 2.5.9 Displaying the Result of the Calculation
        10. 2.5.10 Java API Documentation
      6. 2.6 Memory Concepts
      7. 2.7 Arithmetic
        1. Arithmetic Expressions in Straight-Line Form
        2. Parentheses for Grouping Subexpressions
        3. Rules of Operator Precedence
        4. Sample Algebraic and Java Expressions
        5. Evaluation of a Second-Degree Polynomial
      8. 2.8 Decision Making: Equality and Relational Operators
        1. White space
        2. Operators Discussed So Far
      9. 2.9 Wrap-Up
      10. Summary
        1. Section 2.2 Your First Program in Java: Printing a Line of Text
        2. Section 2.3 Modifying Your First Java Program
        3. Section 2.4 Displaying Text with printf
        4. Section 2.5 Another Application: Adding Integers
        5. Section 2.6 Memory Concepts
        6. Section 2.7 Arithmetic
        7. Section 2.8 Decision Making: Equality and Relational Operators
      11. Self-Review Exercises
      12. Answers to Self-Review Exercises
      13. Exercises
      14. Making a Difference
    12. 3. Introduction to Classes, Objects, Methods and Strings
      1. 3.1 Introduction
      2. 3.2 Instance Variables, set Methods and get Methods
        1. 3.2.1 Account Class with an Instance Variable, a set Method and a get Method
        2. 3.2.2 AccountTest Class That Creates and Uses an Object of Class Account
        3. 3.2.3 Compiling and Executing an App with Multiple Classes
        4. 3.2.4 Account UML Class Diagram with an Instance Variable and set and get Methods
        5. 3.2.5 Additional Notes on Class AccountTest
        6. 3.2.6 Software Engineering with private Instance Variables and public set and get Methods
      3. 3.3 Primitive Types vs. Reference Types
      4. 3.4 Account Class: Initializing Objects with Constructors
        1. 3.4.1 Declaring an Account Constructor for Custom Object Initialization
        2. 3.4.2 Class AccountTest: Initializing Account Objects When They’re Created
      5. 3.5 Account Class with a Balance; Floating-Point Numbers
        1. 3.5.1 Account Class with a balance Instance Variable of Type double
        2. 3.5.2 AccountTest Class to Use Class Account
      6. 3.6 (Optional) GUI and Graphics Case Study: Using Dialog Boxes
        1. Displaying Text in a Dialog Box
        2. JOptionPane Class static Method showMessagDialog
        3. Introducing static Methods
        4. Entering Text in a Dialog
        5. JOptionPane Class static Method showInputDialog
        6. String Class static Method format
        7. GUI and Graphics Case Study Exercise
      7. 3.7 Wrap-Up
      8. 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 Primitive Types vs. Reference Types
        9. Section 3.4 Account Class: Initializing Objects with Constructors
        10. Section 3.5 Account Class with a Balance; Floating-Point Numbers and Type double
      9. Self-Review Exercises
      10. Answers to Self-Review Exercises
      11. Exercises
      12. Making a Difference
    13. 4. Control Statements: Part 1; Assignment, ++ and -- Operators
      1. 4.1 Introduction
      2. 4.2 Algorithms
      3. 4.3 Pseudocode
      4. 4.4 Control Structures
        1. Sequence Structure in Java
        2. Selection Statements in Java
        3. Repetition Statements in Java
        4. Summary of Control Statements in Java
      5. 4.5 if Single-Selection Statement
        1. UML Activity Diagram for an if Statement
      6. 4.6 if...else Double-Selection Statement
        1. UML Activity Diagram for an if...else Statement
        2. Nested if...else Statements
        3. Dangling-else Problem
        4. Blocks
        5. Conditional Operator (?:)
      7. 4.7 Student Class: Nested if...else Statements
        1. Class Student
        2. Class StudentTest
      8. 4.8 while Repetition Statement
        1. UML Activity Diagram for a while Statement
      9. 4.9 Formulating Algorithms: Counter-Controlled Repetition
        1. Pseudocode Algorithm with Counter-Controlled Repetition
        2. Implementing Counter-Controlled Repetition
        3. Local Variables in Method main
        4. Initialization Phase: Initializing Variables total and gradeCounter
        5. Processing Phase: Reading 10 Grades from the User
        6. Termination Phase: Calculating and Displaying the Class Average
        7. Notes on Integer Division and Truncation
        8. A Note About Arithmetic Overflow
        9. A Deeper Look at Receiving User Input
      10. 4.10 Formulating Algorithms: Sentinel-Controlled Repetition
        1. Developing the Pseudocode Algorithm with Top-Down, Stepwise Refinement: The Top and First Refinement
        2. Proceeding to the Second Refinement
        3. Implementing Sentinel-Controlled Repetition
        4. Program Logic for Sentinel-Controlled Repetition vs. Counter-Controlled Repetition
        5. Braces in a while statement
        6. Explicitly and Implicitly Converting Between Primitive Types
        7. Floating-Point Number Precision
      11. 4.11 Formulating Algorithms: Nested Control Statements
        1. Complete Second Refinement of Pseudocode and Conversion to Class Analysis
      12. 4.12 Compound Assignment Operators
      13. 4.13 Increment and Decrement Operators
        1. Difference Between Prefix Increment and Postfix Increment Operators
        2. Simplifying Statements with the Arithmetic Compound Assignment, Increment and Decrement Operators
        3. Operator Precedence and Associativity
      14. 4.14 Primitive Types
      15. 4.15 (Optional) GUI and Graphics Case Study: Creating Simple Drawings
        1. Java’s Coordinate System
        2. First Drawing Application
        3. Method paintComponent
        4. Class DrawPanelTest
        5. GUI and Graphics Case Study Exercises
      16. 4.16 Wrap-Up
      17. Summary
        1. Section 4.1 Introduction
        2. Section 4.2 Algorithms
        3. Section 4.3 Pseudocode
        4. Section 4.4 Control Structures
        5. Section 4.5 if Single-Selection Statement
        6. Section 4.6 if...else Double-Selection Statement
        7. Section 4.8 while Repetition Statement
        8. Section 4.9 Formulating Algorithms: Counter-Controlled Repetition
        9. Section 4.10 Formulating Algorithms: Sentinel-Controlled Repetition
        10. Section 4.12 Compound Assignment Operators
        11. Section 4.13 Increment and Decrement Operators
        12. Section 4.14 Primitive Types
      18. Self-Review Exercises
      19. Answers to Self-Review Exercises
      20. Exercises
      21. Making a Difference
    14. 5. Control Statements: Part 2; Logical Operators
      1. 5.1 Introduction
      2. 5.2 Essentials of Counter-Controlled Repetition
      3. 5.3 for Repetition Statement
        1. A Closer Look at the for Statement’s Header
        2. General Format of a for Statement
        3. Representing a for Statement with an Equivalent while Statement
        4. Scope of a for Statement’s Control Variable
        5. Expressions in a for Statement’s Header Are Optional
        6. Placing Arithmetic Expressions in a for Statement’s Header
        7. Using a for Statement’s Control Variable in the Statement’s Body
        8. UML Activity Diagram for the for Statement
      4. 5.4 Examples Using the for Statement
        1. Application: Summing the Even Integers from 2 to 20
        2. Application: Compound-Interest Calculations
        3. Formatting Strings with Field Widths and Justification
        4. Performing the Interest Calculations with static Method pow of Class Math
        5. Formatting Floating-Point Numbers
        6. A Warning about Displaying Rounded Values
      5. 5.5 do...while Repetition Statement
        1. UML Activity Diagram for the do...while Repetition Statement
        2. Braces in a do...while Repetition Statement
      6. 5.6 switch Multiple-Selection Statement
        1. Using a switch Statement to Count A, B, C, D and F Grades
        2. Reading Grades from the User
        3. Processing the Grades
        4. case without a break Statement
        5. The default Case
        6. Displaying the Grade Report
        7. switch Statement UML Activity Diagram
        8. Notes on the Expression in Each case of a switch
      7. 5.7 Class AutoPolicy Case Study: Strings in switch Statements
        1. Class AutoPolicy
        2. Class AutoPolicyTest
      8. 5.8 break and continue Statements
        1. break Statement
        2. continue Statement
      9. 5.9 Logical Operators
        1. Conditional AND (&&) Operator
        2. Conditional OR (||) Operator
        3. Short-Circuit Evaluation of Complex Conditions
        4. Boolean Logical AND (&) and Boolean Logical Inclusive OR (|) Operators
        5. Boolean Logical Exclusive OR (^)
        6. Logical Negation (!) Operator
        7. Logical Operators Example
        8. Precedence and Associativity of the Operators Presented So Far
      10. 5.10 Structured Programming Summary
        1. Java Control Statements Are Single-Entry/Single-Exit
        2. Rules for Forming Structured Programs
        3. Three Forms of Control
      11. 5.11 (Optional) GUI and Graphics Case Study: Drawing Rectangles and Ovals
        1. Class ShapesTest
        2. GUI and Graphics Case Study Exercises
      12. 5.12 Wrap-Up
      13. Summary
        1. Section 5.2 Essentials of Counter-Controlled Repetition
        2. Section 5.3 for Repetition Statement
        3. Section 5.4 Examples Using the for Statement
        4. Section 5.5 do...while Repetition Statement
        5. Section 5.6 switch Multiple-Selection Statement
        6. Section 5.7 Class AutoPolicy Case Study: Strings in switch Statements
        7. Section 5.8 break and continue Statements
        8. Section 5.9 Logical Operators
      14. Self-Review Exercises
      15. Answers to Self-Review Exercises
      16. Exercises
      17. Making a Difference
    15. 6. Methods: A Deeper Look
      1. 6.1 Introduction
      2. 6.2 Program Modules in Java
        1. Divide and Conquer with Classes and Methods
        2. Hierarchical Relationship Between Method Calls
      3. 6.3 static Methods, static Fields and Class Math
        1. Math Class Methods
        2. static Variables
        3. Math Class static Constants PI and E
        4. Why Is Method main Declared static?
      4. 6.4 Declaring Methods with Multiple Parameters
        1. The public and static Keywords
        2. Method maximum
        3. Implementing Method maximum by Reusing Method Math.max
        4. Assembling Strings with String Concatenation
      5. 6.5 Notes on Declaring and Using Methods
      6. 6.6 Method-Call Stack and Stack Frames
      7. 6.7 Argument Promotion and Casting
      8. 6.8 Java API Packages
      9. 6.9 Case Study: Secure Random-Number Generation
        1. Moving to Secure Random Numbers
        2. Creating a SecureRandom Object
        3. Obtaining a Random int Value
        4. Changing the Range of Values Produced By nextInt
        5. Rolling a Six-Sided Die
        6. Rolling a Six-Sided Die 20 Times
        7. Rolling a Six-Sided Die 6,000,000 Times
        8. Generalized Scaling and Shifting of Random Numbers
        9. A Note About Performance
      10. 6.10 Case Study: A Game of Chance; Introducing enum Types
        1. Method rollDice
        2. Method main’s Local Variables
        3. enum Type Status
        4. Logic of the main Method
        5. Why Some Constants Are Not Defined as enum Constants
      11. 6.11 Scope of Declarations
        1. Principle of Least Privilege
      12. 6.12 Method Overloading
        1. Declaring Overloaded Methods
        2. Distinguishing Between Overloaded Methods
        3. Return Types of Overloaded Methods
      13. 6.13 (Optional) GUI and Graphics Case Study: Colors and Filled Shapes
        1. GUI and Graphics Case Study Exercises
      14. 6.14 Wrap-Up
      15. Summary
        1. Section 6.1 Introduction
        2. Section 6.2 Program Modules in Java
        3. Section 6.3 static Methods, static Fields and Class Math
        4. Section 6.4 Declaring Methods with Multiple Parameters
        5. Section 6.5 Notes on Declaring and Using Methods
        6. Section 6.6 Method-Call Stack and Stack Frames
        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
      16. Self-Review Exercises
      17. Answers to Self-Review Exercises
      18. Exercises
      19. Making a Difference
    16. 7. Arrays and ArrayLists
      1. 7.1 Introduction
        1. Java SE 8
      2. 7.2 Arrays
        1. Logical Array Representation
      3. 7.3 Declaring and Creating Arrays
      4. 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
      5. 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
      6. 7.6 Case Study: Card Shuffling and Dealing Simulation
        1. Class Card
        2. Class DeckOfCards
        3. DeckOfCards Constructor
        4. DeckOfCards Method shuffle
        5. DeckOfCards Method dealCard
        6. Shuffling and Dealing Cards
        7. Preventing NullPointerExceptions
      7. 7.7 Enhanced for Statement
        1. Java SE 8
      8. 7.8 Passing Arrays to Methods
      9. 7.9 Pass-By-Value vs. Pass-By-Reference
      10. 7.10 Case Study: Class GradeBook Using an Array to Store Grades
        1. Storing Student Grades in an Array in Class GradeBook
        2. Class GradeBookTest That Demonstrates Class GradeBook
        3. Java SE 8
      11. 7.11 Multidimensional Arrays
        1. Arrays of One-Dimensional Arrays
        2. Two-Dimensional Arrays with Rows of Different Lengths
        3. Creating Two-Dimensional Arrays with Array-Creation Expressions
        4. Two-Dimensional Array Example: Displaying Element Values
        5. Common Multidimensional-Array Manipulations Performed with for Statements
      12. 7.12 Case Study: Class GradeBook Using a Two-Dimensional Array
        1. Storing Student Grades in a Two-Dimensional Array in Class GradeBook
        2. Methods getMinimum and getMaximum
        3. Method outputBarChart
        4. Method outputGrades
        5. Method getAverage
        6. Class GradeBookTest That Demonstrates Class GradeBook
      13. 7.13 Variable-Length Argument Lists
      14. 7.14 Using Command-Line Arguments
      15. 7.15 Class Arrays
        1. Java SE 8—Class Arrays Method parallelSort
      16. 7.16 Introduction to Collections and Class ArrayList
        1. Demonstrating an ArrayList<String>
        2. Java SE 7—Diamond (<>) Notation for Creating an Object of a Generic Class
      17. 7.17 (Optional) GUI and Graphics Case Study: Drawing Arcs
        1. GUI and Graphics Case Study Exercise
      18. 7.18 Wrap-Up
      19. 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
      20. Self-Review Exercises
      21. Answers to Self-Review Exercises
      22. Exercises
        1. Exercises 7.30-7.34 are reasonably challenging. Once you’ve done them, you ought to be able to implement most popular card games easily.
      23. Special Section: Building Your Own Computer
      24. Making a Difference
    17. 8. Classes and Objects: A Deeper Look
      1. 8.1 Introduction
      2. 8.2 Time Class Case Study
        1. Time1 Class Declaration
        2. Default Constructor
        3. Method setTime and Throwing Exceptions
        4. Method toUniversalString
        5. Method toString
        6. Using Class Time1
        7. Calling Time1 Method setTime with Invalid Values
        8. Software Engineering of the Time1 Class Declaration
        9. Java SE 8—Date/Time API
      3. 8.3 Controlling Access to Members
      4. 8.4 Referring to the Current Object’s Members with the this Reference
      5. 8.5 Time Class Case Study: Overloaded Constructors
        1. Class Time2 with Overloaded Constructors
        2. Class Time2’s Constructors—Calling One Constructor from Another via this
        3. Class Time2’s setTime Method
        4. Notes Regarding Class Time2’s set and get Methods and Constructors
      6. 8.6 Default and No-Argument Constructors
      7. 8.7 Notes on Set and Get Methods
        1. Set and Get Methods vs. public Data
        2. Validity Checking in Set Methods
        3. Predicate Methods
      8. 8.8 Composition
        1. Class Date
        2. Class Employee
        3. Class EmployeeTest
      9. 8.9 enum Types
        1. Declaring Instance Variables, a Constructor and Methods in an enum Type
      10. 8.10 Garbage Collection
        1. A Note about Class Object’s finalize Method
      11. 8.11 static Class Members
        1. Motivating static
        2. Class Scope
        3. static Methods Cannot Directly Access Instance Variables and Instance Methods
        4. Tracking the Number of Employee Objects That Have Been Created
        5. Class EmployeeTest
      12. 8.12 static Import
        1. static Import Forms
        2. Demonstrating static Import
      13. 8.13 final Instance Variables
      14. 8.14 Package Access
      15. 8.15 Using BigDecimal for Precise Monetary Calculations
        1. Interest Calculations Using BigDecimal
        2. Creating BigDecimal Objects
        3. Performing the Interest Calculations with BigDecimal
        4. Formatting Currency Values with NumberFormat
        5. Rounding BigDecimal Values
        6. Scaling BigDecimal Values
      16. 8.16 (Optional) GUI and Graphics Case Study: Using Objects with Graphics
        1. Class MyLine
        2. Class DrawPanel
        3. Class TestDraw
        4. GUI and Graphics Case Study Exercise
      17. 8.17 Wrap-Up
      18. 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
      19. Self-Review Exercise
      20. Answers to Self-Review Exercise
      21. Exercises
      22. Making a Difference
    18. 9. Object-Oriented Programming: Inheritance
      1. 9.1 Introduction
      2. 9.2 Superclasses and Subclasses
        1. University Community Member Hierarchy
        2. Shape Hierarchy
      3. 9.3 protected Members
      4. 9.4 Relationship Between Superclasses and Subclasses
        1. 9.4.1 Creating and Using a CommissionEmployee Class
        2. 9.4.2 Creating and Using a BasePlusCommissionEmployee Class
        3. 9.4.3 Creating a CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy
        4. 9.4.4 CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy Using protected Instance Variables
        5. 9.4.5 CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy Using private Instance Variables
      5. 9.5 Constructors in Subclasses
      6. 9.6 Class Object
      7. 9.7 (Optional) GUI and Graphics Case Study: Displaying Text and Images Using Labels
        1. GUI and Graphics Case Study Exercise
      8. 9.8 Wrap-Up
      9. 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
      10. Self-Review Exercises
      11. Answers to Self-Review Exercises
      12. Exercises
    19. 10. Object-Oriented Programming: Polymorphism and Interfaces
      1. 10.1 Introduction
        1. Implementing for Extensibility
        2. Chapter Overview
        3. Programming in the Specific
        4. Interfaces
      2. 10.2 Polymorphism Examples
        1. Quadrilaterals
        2. Space Objects in a Video Game
      3. 10.3 Demonstrating Polymorphic Behavior
      4. 10.4 Abstract Classes and Methods
        1. Purpose of Abstract Classes
        2. Declaring an Abstract Class and Abstract Methods
        3. Using Abstract Classes to Declare Variables
        4. Layered Software Systems
      5. 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
      6. 10.6 Allowed Assignments Between Superclass and Subclass Variables
      7. 10.7 final Methods and Classes
        1. Final Methods Cannot Be Overridden
        2. Final Classes Cannot Be Superclasses
      8. 10.8 A Deeper Explanation of Issues with Calling Methods from Constructors
      9. 10.9 Creating and Using Interfaces
        1. Standardizing Interactions
        2. Software Objects Communicate Via Interfaces
        3. Using an Interface
        4. Relating Disparate Types
        5. Interfaces vs. Abstract Classes
        6. Tagging Interfaces
        7. 10.9.1 Developing a Payable Hierarchy
        8. 10.9.2 Interface Payable
        9. 10.9.3 Class Invoice
        10. 10.9.4 Modifying Class Employee to Implement Interface Payable
        11. 10.9.5 Modifying Class SalariedEmployee for Use in the Payable Hierarchy
        12. 10.9.6 Using Interface Payable to Process Invoices and Employees Polymorphically
        13. 10.9.7 Some Common Interfaces of the Java API
      10. 10.10 Java SE 8 Interface Enhancements
        1. 10.10.1 default Interface Methods
        2. 10.10.2 static Interface Methods
        3. 10.10.3 Functional Interfaces
      11. 10.11 (Optional) GUI and Graphics Case Study: Drawing with Polymorphism
        1. GUI and Graphics Case Study Exercises
      12. 10.12 Wrap-Up
      13. 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.7 final Methods and Classes
        6. Section 10.9 Creating and Using Interfaces
        7. Section 10.10 Java SE 8 Interface Enhancements
      14. Self-Review Exercises
      15. Answers to Self-Review Exercises
      16. Exercises
      17. Making a Difference
    20. 11. Exception Handling: A Deeper Look
      1. 11.1 Introduction
      2. 11.2 Example: Divide by Zero without Exception Handling
        1. Stack Trace
        2. Stack Trace for an ArithmeticException
        3. Stack Trace for an InputMismatchException
        4. Program Termination
      3. 11.3 Example: Handling ArithmeticExceptions and InputMismatchExceptions
        1. Enclosing Code in a try Block
        2. Catching Exceptions
        3. Multi-catch
        4. Uncaught Exceptions
        5. Termination Model of Exception Handling
        6. Using the throws Clause
      4. 11.4 When to Use Exception Handling
      5. 11.5 Java Exception Hierarchy
        1. Checked vs. Unchecked Exceptions
        2. RuntimeExceptions Are Unchecked Exceptions
        3. Checked Exceptions
        4. The Compiler and Checked Exceptions
        5. The Compiler and Unchecked Exceptions
        6. Catching Subclass Exceptions
        7. Only the First Matching catch Executes
      6. 11.6 finally Block
        1. When the finally Block Executes
        2. Releasing Resources in a finally Block
        3. Demonstrating the finally Block
        4. Throwing Exceptions Using the throw Statement
        5. Rethrowing Exceptions
      7. 11.7 Stack Unwinding and Obtaining Information from an Exception Object
        1. Stack Unwinding
        2. Obtaining Data from an Exception Object
      8. 11.8 Chained Exceptions
        1. Program Flow of Control
        2. Program Output
      9. 11.9 Declaring New Exception Types
        1. A New Exception Type Must Extend an Existing One
        2. Example of a Custom Exception Class
      10. 11.10 Preconditions and Postconditions
        1. Preconditions
        2. Postconditions
        3. Throwing Exceptions When Preconditions or Postconditions Are Not Met
      11. 11.11 Assertions
      12. 11.12 try-with-Resources: Automatic Resource Deallocation
      13. 11.13 Wrap-Up
      14. Summary
        1. Section 11.1 Introduction
        2. Section 11.2 Example: Divide by Zero without Exception Handling
        3. Section 11.3 Example: Handling ArithmeticExceptions and InputMismatchExceptions
        4. Section 11.4 When to Use Exception Handling
        5. Section 11.5 Java Exception Hierarchy
        6. Section 11.6 finally Block
        7. Section 11.7 Stack Unwinding and Obtaining Information from an Exception Object
        8. Section 11.8 Chained Exceptions
        9. Section 11.9 Declaring New Exception Types
        10. Section 11.10 Preconditions and Postconditions
        11. Section 11.11 Assertions
        12. Section 11.12 try-with-Resources: Automatic Resource Deallocation
      15. Self-Review Exercises
      16. Answers to Self-Review Exercises
      17. Exercises
    21. 12. GUI Components: Part 1
      1. 12.1 Introduction
        1. IDE Support for GUI Design
        2. Sample GUI: The SwingSet3 Demo Application
      2. 12.2 Java’s Nimbus Look-and-Feel
      3. 12.3 Simple GUI-Based Input/Output with JOptionPane
        1. Input Dialogs
        2. Converting Strings to int Values
        3. Message Dialogs
        4. JOptionPane Message Dialog Constants
      4. 12.4 Overview of Swing Components
        1. Swing vs. AWT
        2. Lightweight vs. Heavyweight GUI Components
        3. Superclasses of Swing’s Lightweight GUI Components
      5. 12.5 Displaying Text and Images in a Window
        1. Labeling GUI Components
        2. Specifying the Layout
        3. Creating and Attaching label1
        4. The Icon Interface and Class ImageIcon
        5. Loading an Image Resource
        6. Creating and Attaching label2
        7. Creating and Attaching label3
        8. Creating and Displaying a LabelFrame Window
      6. 12.6 Text Fields and an Introduction to Event Handling with Nested Classes
        1. Creating the GUI
        2. Steps Required to Set Up Event Handling for a GUI Component
        3. Using a Nested Class to Implement an Event Handler
        4. Inner Class TextFieldHandler
        5. Registering the Event Handler for Each Text Field
        6. Details of Class TextFieldHandler’s actionPerformed Method
        7. Class TextFieldTest
        8. Java SE 8: Implementing Event Listeners with Lambdas
      7. 12.7 Common GUI Event Types and Listener Interfaces
      8. 12.8 How Event Handling Works
        1. Registering Events
        2. Event-Handler Invocation
      9. 12.9 JButton
        1. Accessing the this Reference in an Object of a Top-Level Class from an Inner Class
      10. 12.10 Buttons That Maintain State
        1. 12.10.1 JCheckBox
        2. 12.10.2 JRadioButton
      11. 12.11 JComboBox; Using an Anonymous Inner Class for Event Handling
        1. Using an Anonymous Inner Class for Event Handling
        2. Java SE 8: Implementing Anonymous Inner Classes with Lambdas
      12. 12.12 JList
      13. 12.13 Multiple-Selection Lists
      14. 12.14 Mouse Event Handling
        1. Tracking Mouse Events on a JPanel
      15. 12.15 Adapter Classes
        1. Extending MouseAdapter
      16. 12.16 JPanel Subclass for Drawing with the Mouse
        1. Method paintComponent
        2. Defining the Custom Drawing Area
        3. Using the Custom JPanel in an Application
      17. 12.17 Key Event Handling
      18. 12.18 Introduction to Layout Managers
        1. 12.18.1 FlowLayout
        2. 12.18.2 BorderLayout
        3. 12.18.3 GridLayout
      19. 12.19 Using Panels to Manage More Complex Layouts
      20. 12.20 JTextArea
        1. JScrollPane Scrollbar Policies
      21. 12.21 Wrap-Up
      22. Summary
        1. Section 12.1 Introduction
        2. Section 12.2 Java’s Nimbus Look-and-Feel
        3. Section 12.3 Simple GUI-Based Input/Output with JOptionPane
        4. Section 12.4 Overview of Swing Components
        5. Section 12.5 Displaying Text and Images in a Window
        6. Section 12.6 Text Fields and an Introduction to Event Handling with Nested Classes
        7. Section 12.7 Common GUI Event Types and Listener Interfaces
        8. Section 12.8 How Event Handling Works
        9. Section 12.9 JButton
        10. Section 12.10 Buttons That Maintain State
        11. Section 12.11 JComboBox; Using an Anonymous Inner Class for Event Handling
        12. Section 12.12 JList
        13. Section 12.13 Multiple-Selection Lists
        14. Section 12.14 Mouse Event Handling
        15. Section 12.15 Adapter Classes
        16. Section 12.16 JPanel Subclass for Drawing with the Mouse
        17. Section 12.17 Key Event Handling
        18. Section 12.18 Introduction to Layout Managers
        19. Section 12.19 Using Panels to Manage More Complex Layouts
        20. Section 12.20 JTextArea
      23. Self-Review Exercises
      24. Answers to Self-Review Exercises
      25. Exercises
        1. (Optional) GUI and Graphics Case Study Exercise: Expanding the Interface
      26. Making a Difference
    22. 13. Graphics and Java 2D
      1. 13.1 Introduction
      2. 13.2 Graphics Contexts and Graphics Objects
      3. 13.3 Color Control
        1. Drawing in Different Colors
      4. 13.4 Manipulating Fonts
        1. Font Metrics
      5. 13.5 Drawing Lines, Rectangles and Ovals
      6. 13.6 Drawing Arcs
      7. 13.7 Drawing Polygons and Polylines
      8. 13.8 Java 2D API
        1. Lines, Rectangles, Round Rectangles, Arcs and Ellipses
        2. Ovals, Gradient Fills and Paint Objects
        3. Rectangles, Strokes
        4. Rounded Rectangles, BufferedImages and TexturePaint Objects
        5. Arcs
        6. Lines
        7. Creating Your Own Shapes with General Paths
      9. 13.9 Wrap-Up
      10. Summary
        1. Section 13.1 Introduction
        2. Section 13.2 Graphics Contexts and Graphics Objects
        3. Section 13.3 Color Control
        4. Section 13.4 Manipulating Fonts
        5. Section 13.5 Drawing Lines, Rectangles and Ovals
        6. Section 13.6 Drawing Arcs
        7. Section 13.7 Drawing Polygons and Polylines
        8. Section 13.8 Java 2D API
      11. Self-Review Exercises
      12. Answers to Self-Review Exercises
      13. Exercises
        1. (Optional) GUI and Graphics Case Study Exercise: Adding Java 2D
      14. Making a Difference
    23. 14. Strings, Characters and Regular Expressions
      1. 14.1 Introduction
      2. 14.2 Fundamentals of Characters and Strings
      3. 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
        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
      4. 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
      5. 14.5 Class Character
      6. 14.6 Tokenizing Strings
      7. 14.7 Regular Expressions, Class Pattern and Class Matcher
        1. Quantifiers
        2. Replacing Substrings and Splitting Strings
        3. Classes Pattern and Matcher
        4. Java SE 8
      8. 14.8 Wrap-Up
      9. 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
      10. Self-Review Exercises
      11. Answers to Self-Review Exercises
      12. Exercises
      13. Special Section: Advanced String-Manipulation Exercises
      14. Special Section: Challenging String-Manipulation Projects
      15. Making a Difference
    24. 15. Files, Streams and Object Serialization
      1. 15.1 Introduction
      2. 15.2 Files and Streams
        1. Byte-Based and Character-Based Streams
        2. Standard Input, Standard Output and Standard Error Streams
        3. The java.io and java.nio Packages
        4. Java SE 8 Adds Another Type of Stream
      3. 15.3 Using NIO Classes and Interfaces to Get File and Directory Information
        1. Creating Path Objects
        2. Absolute vs. Relative Paths
        3. Getting Path Objects from URIs
        4. Example: Getting File and Directory Information
        5. Separator Characters
      4. 15.4 Sequential-Access Text Files
        1. 15.4.1 Creating a Sequential-Access Text File
        2. 15.4.2 Reading Data from a Sequential-Access Text File
        3. 15.4.3 Case Study: A Credit-Inquiry Program
        4. 15.4.4 Updating Sequential-Access Files
      5. 15.5 Object Serialization
        1. Classes ObjectInputStream and ObjectOutputStream
        2. Interfaces ObjectOutput and ObjectInput
        3. 15.5.1 Creating a Sequential-Access File Using Object Serialization
        4. 15.5.2 Reading and Deserializing Data from a Sequential-Access File
      6. 15.6 Opening Files with JFileChooser
      7. 15.7 (Optional) Additional java.io Classes
        1. 15.7.1 Interfaces and Classes for Byte-Based Input and Output
        2. 15.7.2 Interfaces and Classes for Character-Based Input and Output
      8. 15.8 Wrap-Up
      9. 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-Access Text Files
        5. Section 15.5 Object Serialization
        6. Section 15.6 Opening Files with JFileChooser
        7. Section 15.7 (Optional) Additional java.io Classes
      10. Self-Review Exercises
      11. Answers to Self-Review Exercises
      12. Exercises
      13. Making a Difference
    25. 16. Generic Collections
      1. 16.1 Introduction
        1. Java SE 8
      2. 16.2 Collections Overview
        1. Object-Based Collections
        2. Generic Collections
        3. Choosing a Collection
      3. 16.3 Type-Wrapper Classes
      4. 16.4 Autoboxing and Auto-Unboxing
      5. 16.5 Interface Collection and Class Collections
      6. 16.6 Lists
        1. 16.6.1 ArrayList and Iterator
        2. 16.6.2 LinkedList
      7. 16.7 Collections Methods
        1. 16.7.1 Method sort
        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
      8. 16.8 Stack Class of Package java.util
      9. 16.9 Class PriorityQueue and Interface Queue
      10. 16.10 Sets
        1. Sorted Sets
      11. 16.11 Maps
        1. Map Implementation with Hash Tables
      12. 16.12 Properties Class
      13. 16.13 Synchronized Collections
      14. 16.14 Unmodifiable Collections
      15. 16.15 Abstract Implementations
      16. 16.16 Wrap-Up
      17. 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 Stack Class of Package java.util
        9. Section 16.9 Class PriorityQueue and Interface Queue
        10. Section 16.10 Sets
        11. Section 16.11 Maps
        12. Section 16.12 Properties Class
        13. Section 16.13 Synchronized Collections
        14. Section 16.14 Unmodifiable Collections
        15. Section 16.15 Abstract Implementations
      18. Self-Review Exercises
      19. Answers to Self-Review Exercises
      20. Exercises
    26. 17. Java SE 8 Lambdas and Streams
      1. 17.1 Introduction
      2. 17.2 Functional Programming Technologies Overview
        1. External Iteration Is Error Prone
        2. Internal Iteration
        3. 17.2.1 Functional Interfaces
        4. 17.2.2 Lambda Expressions
        5. 17.2.3 Streams
      3. 17.3 IntStream Operations
        1. 17.3.1 Creating an IntStream and Displaying Its Values with the forEach Terminal Operation
        2. 17.3.2 Terminal Operations count, min, max, sum and average
        3. 17.3.3 Terminal Operation reduce
        4. 17.3.4 Intermediate Operations: Filtering and Sorting IntStream Values
        5. 17.3.5 Intermediate Operation: Mapping
        6. 17.3.6 Creating Streams of ints with IntStream Methods range and rangeClosed
      4. 17.4 Stream<Integer> Manipulations
        1. 17.4.1 Creating a Stream<Integer>
        2. 17.4.2 Sorting a Stream and Collecting the Results
        3. 17.4.3 Filtering a Stream and Storing the Results for Later Use
        4. 17.4.4 Filtering and Sorting a Stream and Collecting the Results
        5. 17.4.5 Sorting Previously Collected Results
      5. 17.5 Stream<String> Manipulations
        1. 17.5.1 Mapping Strings to Uppercase Using a Method Reference
        2. 17.5.2 Filtering Strings Then Sorting Them in Case-Insensitive Ascending Order
        3. 17.5.3 Filtering Strings Then Sorting Them in Case-Insensitive Descending Order
      6. 17.6 Stream<Employee> Manipulations
        1. 17.6.1 Creating and Displaying a List<Employee>
        2. 17.6.2 Filtering Employees with Salaries in a Specified Range
        3. 17.6.3 Sorting Employees By Multiple Fields
        4. 17.6.4 Mapping Employees to Unique Last Name Strings
        5. 17.6.5 Grouping Employees By Department
        6. 17.6.6 Counting the Number of Employees in Each Department
        7. 17.6.7 Summing and Averaging Employee Salaries
      7. 17.7 Creating a Stream<String> from a File
        1. Summarizing the Occurrences of Each Word in the File
        2. Displaying the Summary Grouped by Starting Letter
      8. 17.8 Generating Streams of Random Values
        1. Creating an IntStream of Random Values
        2. Converting an IntStream to a Stream<Integer>
        3. Summarizing the Die Frequencies
        4. Displaying the Results
      9. 17.9 Lambda Event Handlers
      10. 17.10 Additional Notes on Java SE 8 Interfaces
        1. Java SE 8 Interfaces Allow Inheritance of Method Implementations
        2. Java SE 8: @FunctionalInterface Annotation
      11. 17.11 Java SE 8 and Functional Programming Resources
      12. 17.12 Wrap-Up
      13. Summary
        1. Section 17.1 Introduction
        2. Section 17.2 Functional Programming Technologies Overview
        3. Section 17.2.1 Functional Interfaces
        4. Section 17.2.2 Lambda Expressions
        5. Section 17.2.3 Streams
        6. Section 17.3 IntStream Operations
        7. Section 17.3.1 Creating an IntStream and Displaying Its Values with the forEach Terminal Operation
        8. Section 17.3.2 Terminal Operations count, min, max, sum and average
        9. Section 17.3.3 Terminal Operation reduce
        10. Section 17.3.4 Intermediate Operations: Filtering and Sorting IntStream Values
        11. Section 17.3.5 Intermediate Operation: Mapping
        12. Section 17.3.6 Creating Streams of ints with IntStream Methods range and rangeClosed
        13. Section 17.4 Stream<Integer> Manipulations
        14. Section 17.4.1 Creating a Stream<Integer>
        15. Section 17.4.2 Sorting a Stream and Collecting the Results
        16. Section 17.4.3 Filtering a Stream and Storing the Results for Later Use
        17. Section 17.4.5 Sorting Previously Collected Results
        18. Section 17.5.1 Mapping Strings to Uppercase Using a Method Reference
        19. Section 17.5.2 Filtering Strings Then Sorting Them in Case-Insensitive Ascending Order
        20. Section 17.5.3 Filtering Strings Then Sorting Them in Case-Insensitive Descending Order
        21. Section 17.6.1 Creating and Displaying a List<Employee>
        22. Section 17.6.2 Filtering Employees with Salaries in a Specified Range
        23. Section 17.6.3 Sorting Employees By Multiple Fields
        24. Section 17.6.4 Mapping Employees to Unique Last Name Strings
        25. Section 17.6.5 Grouping Employees By Department
        26. Section 17.6.6 Counting the Number of Employees in Each Department
        27. Section 17.6.7 Summing and Averaging Employee Salaries
        28. Section 17.7 Creating a Stream<String> from a File
        29. Section 17.8 Generating Streams of Random Values
        30. Section 17.9 Lambda Event Handlers
        31. Section 17.10 Additional Notes on Java SE 8 Interfaces
      14. Self-Review Exercises
      15. Answers to Self-Review Exercises
      16. Exercises
    27. 18. Recursion
      1. 18.1 Introduction
      2. 18.2 Recursion Concepts
      3. 18.3 Example Using Recursion: Factorials
      4. 18.4 Reimplementing Class FactorialCalculator Using Class BigInteger
      5. 18.5 Example Using Recursion: Fibonacci Series
        1. Analyzing the Calls to Method Fibonacci
      6. 18.6 Recursion and the Method-Call Stack
      7. 18.7 Recursion vs. Iteration
      8. 18.8 Towers of Hanoi
      9. 18.9 Fractals
        1. 18.9.1 Koch Curve Fractal
        2. 18.9.2 (Optional) Case Study: Lo Feather Fractal
      10. 18.10 Recursive Backtracking
      11. 18.11 Wrap-Up
      12. 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
      13. Self-Review Exercises
      14. Answers to Self-Review Exercises
      15. Exercises
    28. 19. Searching, Sorting and Big O
      1. 19.1 Introduction
      2. 19.2 Linear Search
        1. Linear Search Algorithm
        2. Linear Search Implementation
        3. Method linearSearch
        4. Method main
      3. 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
      4. 19.4 Binary Search
        1. Example
        2. 19.4.1 Binary Search Implementation
        3. 19.4.2 Efficiency of the Binary Search
      5. 19.5 Sorting Algorithms
      6. 19.6 Selection Sort
        1. 19.6.1 Selection Sort Implementation
        2. 19.6.2 Efficiency of the Selection Sort
      7. 19.7 Insertion Sort
        1. 19.7.1 Insertion Sort Implementation
        2. 19.7.2 Efficiency of the Insertion Sort
      8. 19.8 Merge Sort
        1. 19.8.1 Merge Sort Implementation
        2. 19.8.2 Efficiency of the Merge Sort
      9. 19.9 Big O Summary for This Chapter’s Searching and Sorting Algorithms
      10. 19.10 Wrap-Up
      11. 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
      12. Self-Review Exercises
      13. Answers to Self-Review Exercises
      14. Exercises
    29. 20. Generic Classes and Methods
      1. 20.1 Introduction
      2. 20.2 Motivation for Generic Methods
        1. Common Features in the Overloaded printArray Methods
      3. 20.3 Generic Methods: Implementation and Compile-Time Translation
        1. Type Parameter Section of a Generic Method
        2. Testing the Generic printArray Method
        3. Erasure at Compilation Time
      4. 20.4 Additional Compile-Time Translation Issues: Methods That Use a Type Parameter as the Return Type
        1. Generic Method maximum and Specifying a Type Parameter’s Upper Bound
        2. Calling Method maximum
        3. Erasure and the Upper Bound of a Type Parameter
      5. 20.5 Overloading Generic Methods
      6. 20.6 Generic Classes
        1. Implementing a Generic Stack Class
        2. Testing the Generic Stack Class of Fig. 20.7
        3. Methods testPushDouble and testPopDouble
        4. Methods testPushInteger and testPopInteger
        5. Creating Generic Methods to Test Class Stack<T>
      7. 20.7 Raw Types
        1. Using Raw Types with Generic Class Stack
        2. Compiler Warnings
      8. 20.8 Wildcards in Methods That Accept Type Parameters
        1. Implementing Method sum With a Wildcard Type Argument in Its Parameter
      9. 20.9 Wrap-Up
      10. 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 Raw Types
        8. Section 20.8 Wildcards in Methods That Accept Type Parameters
      11. Self-Review Exercises
      12. Answers to Self-Review Exercises
      13. Exercises
    30. 21. Custom Generic Data Structures
      1. 21.1 Introduction
        1. Optional Online “Building Your Own Compiler” Project
      2. 21.2 Self-Referential Classes
      3. 21.3 Dynamic Memory Allocation
      4. 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
      5. 21.5 Stacks
        1. Stack Class That Inherits from List<T>
        2. Forming a Stack Class Via Composition Rather Than Inheritance
      6. 21.6 Queues
      7. 21.7 Trees
        1. Overview of Class Tree
        2. Tree Method insertNode
        3. TreeNode Method insert
        4. Tree Methods inorderTraversal, preorderTraversal and postorderTraversal
      8. 21.8 Wrap-Up
      9. 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
      10. Self-Review Exercises
      11. Answers to Self-Review Exercises
      12. Exercises
      13. Special Section: Building Your Own Compiler
    31. 22. GUI Components: Part 2
      1. 22.1 Introduction
        1. Java SE 8: Implementing Event Listeners with Lambdas
      2. 22.2 JSlider
      3. 22.3 Understanding Windows in Java
        1. Returning Window Resources to the System
        2. Displaying and Positioning Windows
        3. Window Events
      4. 22.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
      5. 22.5 JPopupMenu
      6. 22.6 Pluggable Look-and-Feel
      7. 22.7 JDesktopPane and JInternalFrame
      8. 22.8 JTabbedPane
      9. 22.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
      10. 22.10 GridBagLayout Layout Manager
        1. GridBagConstraints
        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
      11. 22.11 Wrap-Up
      12. Summary
        1. Section 22.2 JSlider
        2. Section 22.3 Understanding Windows in Java
        3. Section 22.4 Using Menus with Frames
        4. Section 22.5 JPopupMenu
        5. Section 22.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
      13. Self-Review Exercises
      14. Answers to Self-Review Exercises
      15. Exercises
    32. 23. Concurrency
      1. 23.1 Introduction
        1. Java Concurrency
        2. Concurrent Programming Uses
        3. Concurrent Programming Is Difficult
        4. Use the Prebuilt Classes of the Concurrency APIs Whenever Possible
      2. 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
      3. 23.3 Creating and Executing Threads with the Executor Framework
        1. Creating Concurrent Tasks with the Runnable Interface
        2. Executing Runnable Objects with an Executor
        3. Using Class Executors to Obtain an ExecutorService
        4. Implementing the Runnable Interface
        5. Let the Thread Handle InterruptedExceptions
        6. Using the ExecutorService to Manage Threads that Execute PrintTasks
        7. Main Thread
        8. Sample Outputs
        9. Waiting for Previously Scheduled Tasks to Terminate
      4. 23.4 Thread Synchronization
        1. 23.4.1 Immutable Data
        2. 23.4.2 Monitors
        3. 23.4.3 Unsynchronized Mutable Data Sharing
        4. 23.4.4 Synchronized Mutable Data Sharing—Making Operations Atomic
      5. 23.5 Producer/Consumer Relationship without Synchronization
        1. Examples of Producer/Consumer Relationship
        2. Synchronization and State Dependence
        3. Logic Errors from Lack of Synchronization
        4. Interface Buffer
        5. Class Producer
        6. Class Consumer
        7. We Call Thread Method sleep Only for Demonstration Purposes
        8. Class UnsynchronizedBuffer Does Not Synchronize Access to the Buffer
        9. Class SharedBufferTest
      6. 23.6 Producer/Consumer Relationship: ArrayBlockingQueue
        1. Class BlockingBuffer
        2. Class BlockingBufferTest
      7. 23.7 (Advanced) Producer/Consumer Relationship with synchronized, wait, notify and notifyAll
        1. Methods wait, notify and notifyAll
        2. Class SynchronizedBuffer
        3. Fields and Methods of Class SynchronizedBuffer
        4. Method blockingPut and the Producer Thread
        5. Method blockingGet and the Consumer Thread
        6. Method displayState Is Also synchronized
        7. Testing Class SynchronizedBuffer
      8. 23.8 (Advanced) Producer/Consumer Relationship: Bounded Buffers
        1. Bounded Buffers
        2. Bounded Buffers Using ArrayBlockingQueue
        3. Implementing Your Own Bounded Buffer as a Circular Buffer
        4. CircularBuffer Method blockingPut
        5. CircularBuffer Method blockingGet
        6. CircularBuffer Method displayState
        7. Testing Class CircularBuffer
      9. 23.9 (Advanced) Producer/Consumer Relationship: The Lock and Condition Interfaces
        1. Interface Lock and Class ReentrantLock
        2. Condition Objects and Interface Condition
        3. Lock and Condition vs. the synchronized Keyword
        4. Using Locks and Conditions to Implement Synchronization
        5. Class SynchronizedBuffer
        6. Class SharedBufferTest2
      10. 23.10 Concurrent Collections
      11. 23.11 Multithreading with GUI: SwingWorker
        1. Class SwingWorker
        2. 23.11.1 Performing Computations in a Worker Thread: Fibonacci Numbers
        3. 23.11.2 Processing Intermediate Results: Sieve of Eratosthenes
      12. 23.12 sort/parallelSort Timings with the Java SE 8 Date/Time API
        1. Creating the Arrays
        2. Timing Arrays Method sort with Date/Time API Classes Instant and Duration
        3. Timing Arrays Method parallelSort with Date/Time API Classes Instant and Duration
        4. Displaying the Percentage Difference Between the Sorting Times
        5. Other Parallel Array Operations
      13. 23.13 Java SE 8: Sequential vs. Parallel Streams
        1. Performing Stream Operations with Separate Passes of a Sequential Stream
        2. Performing Stream Operations with a Single Pass of a Sequential Stream
        3. Performing Stream Operations with a Single Pass of a Parallel Stream
      14. 23.14 (Advanced) Interfaces Callable and Future
        1. Executing Aysnchronous Tasks with CompletableFuture
        2. Class TimeData
        3. Method startFibonacci for Performing and Timing Fibonacci Calculations
        4. Performing Fibonacci Calculations Synchronously
        5. Performing Fibonacci Calculations Asynchronously
        6. Getting the Asynchronous Calculations’ Results
        7. Program Outputs
      15. 23.15 (Advanced) Fork/Join Framework
      16. 23.16 Wrap-Up
      17. 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.9 (Advanced) Producer/Consumer Relationship: The Lock and Condition Interfaces
        10. Section 23.11 Multithreading with GUI: SwingWorker
        11. Section 23.12 Timing sort and parallelSort with the Java SE 8 Date/Time API
        12. Section 23.13 Java SE 8: Sequential vs. Parallel Streams
        13. Section 23.14 (Advanced) Interfaces Callable and Future
        14. Section 23.15 (Advanced) Fork/Join Framework
      18. Self-Review Exercises
      19. Answers to Self-Review Exercises
      20. Exercises
        1. Parallel Streams
    33. 24. Accessing Databases with JDBC
      1. 24.1 Introduction
        1. Structured Query Language
        2. Popular Relational Database Management Systems
        3. JDBC
        4. Java Persistence API (JPA)
      2. 24.2 Relational Databases
        1. Selecting Data Subsets
      3. 24.3 A books Database
        1. Authors Table
        2. AuthorISBN Table
        3. Entity-Relationship (ER) Diagram
      4. 24.4 SQL
        1. 24.4.1 Basic SELECT Query
        2. 24.4.2 WHERE Clause
        3. 24.4.3 ORDER BY Clause
        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
      5. 24.5 Setting up a Java DB Database
        1. JDK Installation Folders
        2. Java DB Configuration
        3. 24.5.1 Creating the Chapter’s Databases on Windows
        4. 24.5.2 Creating the Chapter’s Databases on Mac OS X
        5. 24.5.3 Creating the Chapter’s Databases on Linux
      6. 24.6 Manipulating Databases with JDBC
        1. 24.6.1 Connecting to and Querying a Database
        2. 24.6.2 Querying the books Database
      7. 24.7 RowSet Interface
        1. Connected and Disconnected RowSets
        2. Using a RowSet
      8. 24.8 PreparedStatements
        1. Address Book Application that Uses PreparedStatements
        2. Class Person
        3. Class PersonQueries
        4. Creating PreparedStatements
        5. PersonQueries Method getAllPeople
        6. PersonQueries Methods addPerson and Close
        7. Class AddressBookDisplay
      9. 24.9 Stored Procedures
      10. 24.10 Transaction Processing
      11. 24.11 Wrap-Up
      12. Summary
        1. Section 24.1 Introduction
        2. Section 24.2 Relational Databases
        3. Section 24.4.1 Basic SELECT Query
        4. Section 24.4.2 WHERE Clause
        5. Section 24.4.3 ORDER BY Clause
        6. Section 24.4.4 Merging Data from Multiple Tables: INNER JOIN
        7. Section 24.4.5 INSERT Statement
        8. Section 24.4.6 UPDATE Statement
        9. Section 24.4.7 DELETE Statement
        10. Section 24.5 Setting up a Java DB Database
        11. Section 24.6.1 Connecting to and Querying a Database
        12. Section 24.6.2 Querying the books Database
        13. Section 24.7 RowSet Interface
        14. Section 24.8 PreparedStatements
        15. Section 24.9 Stored Procedures
        16. Section 24.10 Transaction Processing
      13. Self-Review Exercise
      14. Answers to Self-Review Exercise
      15. Exercises
    34. 25. JavaFX GUI: Part 1
      1. 25.1 Introduction
        1. History of GUI in Java
        2. JavaFX Version Used in This Chapter
      2. 25.2 JavaFX Scene Builder and the NetBeans IDE
        1. What is FXML?
      3. 25.3 JavaFX App Window Structure
      4. 25.4 Welcome App—Displaying Text and an Image
        1. 25.4.1 Creating the App’s Project
        2. 25.4.2 NetBeans Projects Window—Viewing the Project Contents
        3. 25.4.3 Adding an Image to the Project
        4. 25.4.4 Opening JavaFX Scene Builder from NetBeans
        5. 25.4.5 Changing to a VBox Layout Container
        6. 25.4.6 Configuring the VBox Layout Container
        7. 25.4.7 Adding and Configuring a Label
        8. 25.4.8 Adding and Configuring an ImageView
        9. 25.4.9 Running the Welcome App
      5. 25.5 Tip Calculator App—Introduction to Event Handling
        1. 25.5.1 Test-Driving the Tip Calculator App
        2. 25.5.2 Technologies Overview
        3. 25.5.3 Building the App’s GUI
        4. 25.5.4 TipCalculator Class
        5. 25.5.5 TipCalculatorController Class
      6. 25.6 Features Covered in the Online JavaFX Chapters
      7. 25.7 Wrap-Up
      8. Summary
        1. Section 25.1 Introduction
        2. Section 25.2 JavaFX Scene Builder and the NetBeans IDE
        3. Section 25.3 JavaFX App Window Structure
        4. Section 25.4 Welcome App—Displaying Text and an Image
        5. Section 25.5.2 Technologies Overview
        6. Section 25.5.3 Building the App’s GUI
        7. Section 25.5.4 TipCalculator Class
        8. Section 25.5.5 TipCalculatorController Class
      9. Self-Review Exercises
      10. Answers to Self-Review Exercises
      11. Exercises
      12. Making a Difference
    35. Chapters on the Web
      1. A. Operator Precedence Chart
      2. B. ASCII Character Set
      3. C. Keywords and Reserved Words
      4. D. Primitive Types
      5. E. Using the Debugger
        1. E.1 Introduction
        2. E.2 Breakpoints and the run, stop, cont and print Commands
        3. E.3 The print and set Commands
        4. E.4 Controlling Execution Using the step, step up and next Commands
        5. E.5 The watch Command
        6. E.6 The clear Command
        7. E.7 Wrap-Up
    36. Appendices on the Web
    37. Index
    38. Additional Comments from Recent Editions Reviewers
    39. 26. JavaFX GUI: Part 2
      1. 26.1 Introduction
      2. 26.2 Installing JDK 8, NetBeans 8 and JavaFX Scene Builder 2.0
        1. Installing JDK 8 and NetBeans 8
        2. Installing JavaFX Scene Builder 2.0
      3. 26.3 Laying Out Nodes in a Scene Graph
        1. Size of a Node
        2. Position of a Node and Layout Panes
      4. 26.4 Painter App: RadioButtons, Mouse Events and Shapes
        1. 26.4.1 Technologies Overview
        2. JavaFX Shapes
        3. Mouse Event Handling
        4. Setting a Control’s User Data
        5. 26.4.2 Creating the Project
        6. 26.4.3 Building the GUI
        7. 26.4.4 Painter Subclass of Application
        8. 26.4.5 PainterController Class
        9. Instance Variables
      5. 26.5 Color Chooser App: Property Bindings and Property Listeners
        1. 26.5.1 Technologies Overview
        2. Property Bindings
        3. Property Listeners
        4. 26.5.2 Creating the Project
        5. 26.5.3 Building the GUI
        6. Step 7: Configuring the Columns
        7. 26.5.4 ColorChooser Subclass of Application
        8. 26.5.5 ColorChooserController Class
        9. Instance Variables
        10. Property-to-Property Bindings
        11. Property Listeners
      6. 26.6 Cover Viewer App: Data-Drivien GUIs with JavaFX Collections
        1. 26.6.1 Technologies Overview
        2. 26.6.2 Creating the Project
        3. 26.6.3 Adding Images to the Project
        4. 26.6.4 Building the GUI
        5. 26.6.5 CoverViewer Subclass of Application
        6. 26.6.6 CoverViewerController Class
      7. 26.7 Cover Viewer App: Customizing ListView Cells
        1. 26.7.1 Technolgies Overview
        2. Programmatically Creating Layouts and Controls
        3. 26.7.2 Copying the CoverViewer Project
        4. 26.7.3 ImageTextCell Custom Cell Factory Class
        5. 26.7.4 CoverViewerController Class
      8. 26.8 Wrap-Up
        1. Exercises
    40. 28. Networking
      1. 28.1 Introduction
      2. 28.2 Reading a File on a Web Server
      3. 28.3 Establishing a Simple Server Using Stream Sockets
        1. Step 1: Create a ServerSocket
        2. Step 2: Wait for a Connection
        3. Step 3: Get the Socket’s I/O Streams
      4. 28.4 Establishing a Simple Client Using Stream Sockets
        1. Step 1: Create a Socket to Connect to the sServer
        2. Step 2: Get the Socket’s I/O Streams
        3. Step 3: Perform the Processing
        4. Step 4: Close the Connection
      5. 28.5 Client/Server Interaction with Stream Socket Connections
        1. Server Class
      6. 28.6 Datagrams: Connectionless Client/Server Interaction
        1. Server Class
        2. Method waitForPackets
        3. Method displayMessage
        4. Method sendPacketToClient
        5. Client Class
        6. Method waitForPackets
      7. 28.7 Client/Server Tic-Tac-Toe Using a Multithreaded Server
        1. TicTacToeServer Class
      8. 28.8 Optional Online Case Study: DeitelMessenger
      9. 28.9 Wrap-Up
      10. 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
      11. Self-Review Exercises
      12. Answers to Self-Review Exercises
      13. Exercises
    41. 29. Java Persistence API (JPA)
      1. 29.1 Introduction
      2. 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
      3. 29.3 Querying a Database with JPA
        1. 29.3.1 Creating the Java DB Database
        2. 29.3.2 Populate 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
        5. 29.3.5 Creating the Persistence Unit for the books Database
        6. 29.3.6 Querying the Authors Table
        7. 29.3.7 JPA Features of Autogenerated Class Authors
      4. 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 ISBNs
        2. 29.4.2 Using a Named Query to Get the List of Titles, then Display Each with Its Authors
      5. 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 and Its Persistence Unit
        3. 29.5.3 Addresses Entity Class
        4. 29.5.4 AddressBook Class
        5. 29.5.5 Other JPA Operations
      6. 29.6 Web Resources
      7. 29.7 Wrap-Up
      8. Exercises
    42. 30. JavaServer™ Faces Web Apps: Part 1
      1. 30.1 Introduction
        1. Required Software for This Chapter
      2. 30.2 HyperText Transfer Protocol (HTTP) Transactions
        1. XHTML Documents
        2. URLs
        3. Parts of a URL
        4. Making a Request and Receiving a Response
      3. 30.3 Multitier Application Architecture
      4. 30.4 Your First JSF Web App
        1. Executing the WebTime App
        2. 30.4.1 The Default index.xhtml Document: Introducing Facelets
        3. 30.4.2 Examining the WebTimeBean Class
        4. 30.4.3 Building the WebTime JSF Web App in NetBeans
      5. 30.5 Model-View-Controller Architecture of JSF Apps
      6. 30.6 Common JSF Components
        1. h:panelGrid Element
        2. h:graphicImage Element and Resource Libraries
        3. h:inputText Element
        4. h:selectOneMenu Element
        5. h:outputLink Element
        6. h:selectOneMenu Element
        7. h:commandButton Element
      7. 30.7 Validation Using JSF Standard Validators
        1. Validating Form Data in a Web Application
        2. Class ValidationBean
        3. index.xhtml
        4. First Row of the h:panelGrid
        5. Validating the nameInputText Element’s Contents
        6. Second and Third Rows of the h:panelGrid
        7. Validating the e-Mail Address
        8. Validating the Phone Number
        9. Submitting the Form—More Details of the JSF Lifecycle
      8. 30.8 Session Tracking
        1. Personalization
        2. Privacy
        3. Recognizing Clients
        4. 30.8.1 Cookies
        5. 30.8.2 Session Tracking with @SessionScoped Beans
      9. 30.9 Wrap-Up
      10. 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
      11. Self-Review Exercises
      12. Answers to Self-Review Exercises
      13. Exercises

    Product information

    • Title: Java™ How To Program (Early Objects), Tenth Edition
    • Author(s): Paul Deitel, Harvey Deitel
    • Release date: February 2014
    • Publisher(s): Pearson
    • ISBN: 9780133813036