Foreword xxvii Preface xxix Before You Begin xlv Chapter 1: Introduction and Test-Driving a Java Application 1 1.1 Introduction 2 1.2 Object Technology Concepts 3 1.3 Java 6 1.4 A Typical Java Development Environment 8 1.5 Test-Driving a Java Application 11 1.6 Software Technologies 15 1.7 Getting Your Questions Answered 18 Chapter 2: Introduction to Java Applications; Input/Output and Operators 19 2.
1 Introduction 20 2.2 Your First Program in Java: Printing a Line of Text 20 2.3 Modifying Your First Java Program 24 2.4 Displaying Text with printf 26 2.5 Another Application: Adding Integers 27 2.6 Arithmetic 30 2.7 Decision Making: Equality and Relational Operators 31 2.8 Wrap-Up 34 Chapter 3: Introduction to Classes, Objects, Methods and Strings 35 3.
1 Introduction 36 3.2 Instance Variables, set Methods and get Methods 37 3.3 Account Class: Initializing Objects with Constructors 46 3.4 Account Class with a Balance; Floating-Point Numbers 49 3.5 Primitive Types vs. Reference Types 54 3.6 Wrap-Up 55 Chapter 4: Control Statements: Part 1; Assignment, ++ and -- Operators 56 4.1 Introduction 57 4.
2 Control Structures 57 4.3 if Single-Selection Statement 59 4.4 if.else Double-Selection Statement 60 4.5 while Iteration Statement 63 4.6 Counter-Controlled Iteration 65 4.7 Sentinel-Controlled Iteration 68 4.8 Nesting Different Control Statements 72 4.
9 Compound Assignment Operators 74 4.10 Increment and Decrement Operators 75 4.11 Primitive Types 78 4.12 Wrap-Up 78 Chapter 5: Control Statements: Part 2; Logical Operators 79 5.1 Introduction 80 5.2 Essentials of Counter-Controlled Iteration 80 5.3 for Iteration Statement 81 5.4 Examples Using the for Statement 85 5.
5 do.while Iteration Statement 90 5.6 switch Multiple-Selection Statement 90 5.7 Class AutoPolicy: Strings in switch Statements 97 5.8 break and continue Statements 100 5.9 Logical Operators 102 5.10 Wrap-Up 108 Chapter 6: Methods: A Deeper Look 109 6.1 Introduction 110 6.
2 Program Units in Java 110 6.3 static Methods, static Fields and Class Math 111 6.4 Methods with Multiple Parameters 113 6.5 Notes on Declaring and Using Methods 116 6.6 Argument Promotion and Casting 117 6.7 Java API Packages 119 6.8 Case Study: Secure Random-Number Generation 120 6.9 Case Study: A Game of Chance; Introducing enum Types 125 6.
10 Scope of Declarations 129 6.11 Method Overloading 132 6.12 Wrap-Up 134 Chapter 7: Arrays and ArrayLists 135 7.1 Introduction 136 7.2 Arrays 137 7.3 Declaring and Creating Arrays 138 7.4 Examples Using Arrays 139 7.5 Exception Handling: Processing the Incorrect Response 148 7.
6 Case Study: Card Shuffling and Dealing Simulation 149 7.7 Enhanced for Statement 153 7.8 Passing Arrays to Methods 155 7.9 Pass-By-Value vs. Pass-By-Reference 157 7.10 Case Study: Class GradeBook Using an Array to Store Grades 158 7.11 Multidimensional Arrays 163 7.12 Case Study: Class GradeBook Using a Two-Dimensional Array 167 7.
13 Variable-Length Argument Lists 173 7.14 Using Command-Line Arguments 174 7.15 Class Arrays 176 7.16 Introduction to Collections and Class ArrayList 179 7.17 Wrap-Up 182 Chapter 8: Classes and Objects: A Deeper Look 184 8.1 Introduction 185 8.2 Time Class Case Study 185 8.3 Controlling Access to Members 190 8.
4 Referring to the Current Object''s Members with the this Reference 191 8.5 Time Class Case Study: Overloaded Constructors 193 8.6 Default and No-Argument Constructors 198 8.7 Notes on Set and Get Methods 199 8.8 Composition 200 8.9 enum Types 203 8.10 Garbage Collection 206 8.11 static Class Members 206 8.
12 static Import 210 8.13 final Instance Variables 211 8.14 Package Access 212 8.15 Using BigDecimal for Precise Monetary Calculations 213 8.16 JavaMoney API 216 8.17 Time Class Case Study: Creating Packages 216 8.18 Wrap-Up 220 Chapter 9: Object-Oriented Programming: Inheritance 221 9.1 Introduction 222 9.
2 Superclasses and Subclasses 223 9.3 protected Members 225 9.4 Relationship Between Superclasses and Subclasses 226 9.5 Constructors in Subclasses 246 9.6 Class Object 247 9.7 Designing with Composition vs. Inheritance 248 9.8 Wrap-Up 249 Chapter 10: Object-Oriented Programming: Polymorphism and Interfaces 251 10.
1 Introduction 252 10.2 Polymorphism Examples 254 10.3 Demonstrating Polymorphic Behavior 255 10.4 Abstract Classes and Methods 257 10.5 Case Study: Payroll System Using Polymorphism 260 10.6 Allowed Assignments Between Superclass and Subclass Variables 274 10.7 final Methods and Classes 274 10.8 A Deeper Explanation of Issues with Calling Methods from Constructors 275 10.
9 Creating and Using Interfaces 276 10.10 Java SE 8 Interface Enhancements 285 10.11 Java SE 9 private Interface Methods 287 10.12 private Constructors 287 10.13 Program to an Interface, Not an Implementation 288 10.14 Wrap-Up 290 Chapter 11: Exception Handling: A Deeper Look 291 11.1 Introduction 292 11.2 Example: Divide by Zero without Exception Handling 293 11.
3 Example: Handling ArithmeticExceptions and InputMismatchExceptions 295 11.4 When to Use Exception Handling 300 11.5 Java Exception Hierarchy 301 11.6 finally Block 304 11.7 Stack Unwinding and Obtaining Information from an Exception 309 11.8 Chained Exceptions 311 11.9 Declaring New Exception Types 313 11.10 Preconditions and Postconditions 314 11.
11 Assertions 315 11.12 try-with-Resources: Automatic Resource Deallocation 317 11.13 Wrap-Up 318 Chapter 12: JavaFX Graphical User Interfaces: Part 1 319 12.1 Introduction 320 12.2 JavaFX Scene Builder 321 12.3 JavaFX App Window Structure 322 12.4 Welcome App--Displaying Text and an Image 323 12.5 Tip Calculator App--Introduction to Event Handling 328 12.
6 Features Covered in the Other JavaFX Chapters 346 12.7 Wrap-Up 346 Chapter 13: JavaFX GUI: Part 2 347 13.1 Introduction 348 13.2 Laying Out Nodes in a Scene Graph 348 13.3 Painter App: RadioButtons, Mouse Events and Shapes 350 13.4 Color Chooser App: Property Bindings and Property Listeners 360 13.5 Cover Viewer App: Data-Driven GUIs with JavaFX Collections 366 13.6 Cover Viewer App: Customizing ListView Cells 371 13.
7 Additional JavaFX Capabilities 375 13.8 JavaFX 9: Java SE 9 JavaFX Updates 377 13.9 Wrap-Up 379 Chapter 14: Strings, Characters and Regular Expressions 380 14.1 Introduction 381 14.2 Fundamentals of Characters and Strings 381 14.3 Class String 382 14.4 Class StringBuilder 395 14.5 Class Character 402 14.
6 Tokenizing Strings 407 14.7 Regular Expressions, Class Pattern and Class Matcher 408 14.8 Wrap-Up 417 Chapter 15: Files, Input/Output Streams, NIO and XML Serialization 418 15.1 Introduction 419 15.2 Files and Streams 419 15.3 Using NIO Classes and Interfaces to Get File and Directory Information 421 15.4 Sequential Text Files 425 15.5 XML Serialization 434 15.
6 FileChooser and DirectoryChooser Dialogs 441 15.7 (Optional) Additional java.io Classes 447 15.8 Wrap-Up 450 Chapter 16: Generic Collections 451 16.1 Introduction 452 16.2 Collections Overview 452 16.3 Type-Wrapper Classes 454 16.4 Autoboxing and Auto-Unboxing 454 16.
5 Interface Collection and Class Collections 454 16.6 Lists 455 16.7 Collections Methods 463 16.8 Class PriorityQueue and Interface Queue 474 16.9 Sets 475 16.10 Maps 478 16.11 Synchronized Collections 482 16.12 Unmodifiable Collections 482 16.
13 Abstract Implementations 483 16.14 Java SE 9: Convenience Factory Methods for Immutable Collections 483 16.15 Wrap-Up 487 Chapter 17: Lambdas and Streams 488 17.1 Introduction 489 17.2 Streams and Reduction 491 17.3 Mapping and Lambdas 494 17.4 Filtering 498 17.5 How Elements Move Through Stream Pipelines 500 17.
6 Method References 501 17.7 IntStream Operations 504 17.8 Functional Interfaces 509 17.9 Lambdas: A Deeper Look 510 17.10 Stream Manipulations 511 17.11 Stream Manipulations 514 17.12 Stream Manipulations 517 17.13 Creating a Stream from a File 528 17.
14 Streams of Random Values 531 17.15 Infinite Streams 533 17.16 Lambda Event Handlers 535 17.17 Additional Notes on Java SE 8 Interfaces 535 17.18 Wrap-Up 536 Chapter 18: Recursion 537 18.1 Introduction 538 18.2 Recursion Concepts 538 18.3 Example Using Recursion: Factorials 539 18.
4 Reimplementing Class FactorialCalculator Using BigInteger 541 18.5 Example Using Recursion: Fibonacci Series 543 18.6 Recursion and the Method-Call Stack 546 18.7 Recursion vs. Iteration 547 18.8 Towers of Hanoi 549 18.9 Fractals 551 18.10 Recursive Backtracking 561 18.
11 Wrap-Up 562 Chapter 19: Generic Classes and Methods: A Deeper Look 563 19.1 I.