Preface xxv Before You Begin lix Chapter 1: Intro, Test-Driving a Java Application, and Generative AI 1 1.1 Introduction 2 1.2 Hardware 4 1.3 Java 7 1.4 A Brief Review of Object Orientation 8 1.5 Java Application Programming Interface (API) and Open-Source Libraries 11 1.6 Typical Java Program Development Environment 12 1.7 Test-Driving a Java Program with the Java Development Kit (JDK) 15 1.
8 Internet, World Wide Web, the Cloud and IoT 18 1.9 Metaverse 22 1.10 Software Development Technologies 25 1.11 Data Analytics and Data Science 27 1.12 How Big Is Big Data? 28 1.13 AI--at the Intersection of Computer Science and Data Science 32 1.14 Generative AI 35 1.15 Wrap-Up 41 Chapter 2: Intro to Java Programming 47 2.
1 Introduction 48 2.2 Your First Program in Java: Printing a Line of Text 48 2.3 Modifying Your First Program 54 2.4 Displaying Text with printf 56 2.5 Another Program: Adding Integers 57 2.6 Arithmetic 60 2.7 Decision Making: Equality and Relational Operators 62 2.8 Objects-Natural Case Study: Creating and Using Objects of the Java API''s String Class 65 2.
9 Wrap-Up 68 Chapter 3: Control Statements: Part 1 69 3.1 Introduction 70 3.2 Control Structures 70 3.3 if Single-Selection Statement 73 3.4 if.else Double-Selection Statement 74 3.5 while Iteration Statement 77 3.6 Counter-Controlled Iteration 79 3.
7 Sentinel-Controlled Iteration 83 3.8 Nested Control Statements 87 3.9 Compound Assignment Operators 91 3.10 Increment and Decrement Operators 91 3.11 Primitive Types 94 3.12 Objects-Natural Case Study: Super-Sized Integers 94 3.13 Wrap-Up 98 Chapter 4: Control Statements: Part 2 99 4.1 Introduction 100 4.
2 Essentials of Counter-Controlled Iteration 100 4.3 for Iteration Statement 101 4.4 Examples Using the for Statement 104 4.5 Summing the Even Integers from 2 to 20 with the for Statement 105 4.6 Calculating Compound Interest with the for Statement 106 4.7 do.while Iteration Statement 109 4.8 switch Multiple-Selection Statement 111 4.
9 break and continue Statements 116 4.10 Logical Operators 118 4.11 Objects-Natural Case Study: Precise Monetary Calculations with Java API Class BigDecimal 124 4.12 Wrap-Up 128 Chapter 5: Methods 131 5.1 Introduction 132 5.2 Declaring Methods 132 5.3 Notes on Declaring and Using Methods 136 5.4 Case Study: Die Rolling Simulation with Random-Number Generation 137 5.
5 Case Study: A Game of Chance; Introducing enums 142 5.6 Scope of Declarations 147 5.7 Method Overloading 150 5.8 Class Math: static Methods and Variables 152 5.9 Java API Packages 154 5.10 Method-Call Stack and Activation Records 156 5.11 Argument Promotion and Casting 159 5.12 Objects-Natural Case Study: Java Date/Time API 161 5.
13 Wrap-Up 167 Chapter 6: Arrays and ArrayLists 169 6.1 Introduction 170 6.2 Primitive Types vs. Reference Types 171 6.3 Arrays 171 6.4 Declaring and Creating Arrays 172 6.5 Creating and Initializing an Array 173 6.6 Array Initializers 175 6.
7 Calculating Array Element Values 176 6.8 Totaling Array Elements 177 6.9 Intro to Visualization: Using a Bar Chart to Display Array Data Graphically 177 6.10 Using Array Elements as Counters 179 6.11 Analyzing Survey Results 181 6.12 Exception Handling 183 6.13 Enhanced for Statement: Totaling Array Elements 184 6.14 Passing Arrays to Methods 186 6.
15 Pass-By-Value vs. Pass-By-Reference 188 6.16 Multidimensional Arrays 189 6.17 Variable-Length Argument Lists 193 6.18 Command-Line Arguments 194 6.19 Class Arrays 197 6.20 Objects-Natural Case Study: Intro to Collections and Class ArrayList 199 6.21 Wrap-Up 204 Chapter 7: Strings, NLP and Regex: Generative AI Foundations 207 7.
1 Introduction 208 7.2 Fundamentals of Characters and Strings 209 7.3 Class String 210 7.4 Class StringBuilder 225 7.5 Class Character 232 7.6 Tokenizing Strings 237 7.7 Intro to Natural Language Processing (NLP)--at the Root of Generative AI 238 7.8 Objects-Natural Case Study: Intro to Regular Expressions in NLP 240 7.
9 Objects-Natural Security Case Study: pMa5tfEKwk59dTvC04Ft1IFQz9mEXnkfYXZwxk4ujGE= 252 7.10 Wrap-Up 260 Chapter 8: Real-World Modeling with Custom Classes 261 8.1 Introduction 262 8.2 Instance Variables, set Methods and get Methods 263 8.3 Default and Explicit Instance Variable Initialization 271 8.4 Account Class: Initializing Objects with Constructors 271 8.5 Account Class with a Balance 274 8.6 Case Study: Card Shuffling and Dealing Simulation 278 8.
7 Case Study: Time Class 283 8.8 Controlling Access to Members 286 8.9 Referring to the Current Object''s Members with the this Reference 287 8.10 Case Study: Time Class Overloaded Constructors 289 8.11 Default and No-Argument Constructors 296 8.12 Notes on Set and Get Methods 296 8.13 Composition 297 8.14 enum Types 300 8.
15 Garbage Collection 303 8.16 static Class Members 303 8.17 static Import 307 8.18 final Instance Variables 308 8.19 Package Access 309 8.20 record Classes 310 8.21 Wrap-Up 315 Chapter 9: Real-World Modeling with Inheritance, Polymorphism & Interfaces 317 9.1 Introduction 318 9.
2 Superclasses and Subclasses 320 9.3 Relationship Between Superclasses and Subclasses 322 9.4 Class Object 332 9.5 Intro to Polymorphism: Polymorphic Video Game 332 9.6 Demonstrating Polymorphic Behavior 333 9.7 abstract Classes and Methods 336 9.8 Case Study: Payroll System Using Polymorphism 338 9.9 final Methods and Classes 347 9.
10 Issues with Constructors Calling Instance Methods 348 9.11 Creating and Using Interfaces 349 9.12 Other Interface Features 357 9.13 Program to an Interface, Not an Implementation 359 9.14 sealed Classes and Interfaces 367 9.15 private Constructors 370 9.16 protected Members 370 9.17 Wrap-Up 372 Chapter 10: Exception Handling: A Deeper Look 375 10.
1 Introduction 376 10.2 Example: Divide by Zero without Exception Handling 378 10.3 Example: Handling ArithmeticExceptions and InputMismatchExceptions 380 10.4 Java Exception Hierarchy 384 10.5 Checked vs. Unchecked Exceptions 386 10.6 finally Block 388 10.7 Stack Unwinding and Obtaining Information from an Exception 390 10.
8 Chained Exceptions 394 10.9 Declaring Custom Exceptions 396 10.10 Preconditions and Postconditions 397 10.11 Assertions 398 10.12 try-with-Resources Statement: Automatic Resource Deallocation 399 10.13 Unnamed Variables in catch Handlers 401 10.14 Wrap-Up 402 Chapter 11: Files, I/O Streams, JSON Serialization & CSV Files 405 11.1 Introduction 406 11.
2 Files and Streams 407 11.3 Using NIO Classes and Interfaces to Get File and Directory Information 409 11.4 Sequential Text Files 413 11.5 Case Study: JavaScript Object Notation (JSON) Serialization 418 11.6 Case Study: Processing a JSON Response from a Web Service 424 11.7 Case Study: Creating and Reading CSV Files 432 11.8 Case Study: Reading and Analyzing a CSV File Containing the Titanic Disaster Dataset 437 11.9 Objects-Natural Security Case Study: RSA Public-Key Cryptography 445 11.
10 Wrap-Up 452 Chapter 12: Generic Collections 455 12.1 Introduction 456 12.2 Collections Overview 457 12.3 Type-Wrapper Classes 458 12.4 Boxing and Unboxing 459 12.5 Lists 459 12.6 Collections Methods 468 12.7 Class PriorityQueue and Interface Queue 480 12.
8 Hash Tables 481 12.9 Sets 483 12.10 Maps 486 12.11 Convenience Factory Methods for Creating Immutable Collections 489 12.12 Concurrent Collections 492 12.13 Wrap-Up 492 Chapter 13: Generic Classes and Methods: A Deeper Look 495 13.1 Introduction 496 13.2 Motivation for Generic Methods 496 13.
3 Generic Methods: Implementation and Compile-Time Translation 498 13.4 Additional Compile-Time Translation Issues: Methods That Use a Type Parameter as the Return Type 501 13.5 Overloading Generic Methods 505 13.6 Generic Classes 505 13.7 Wildcards in Methods That Accept Type Parameters 513 13.8 Wrap-Up 517 Chapter 14: Functional Programming with Lambdas & Streams 519 14.1 Introduction 520 14.2 Streams and Reduction 521 14.
3 Mapping and Lambdas 525 14.4 Filtering 528 14.5 How Elements Move Through Stream Pipelines 530 14.6 Method References 531 14.7 IntStream Operations 534 14.8 Functional Interfaces 540 14.9 Lambdas: A Deeper Look 541 14.10 Stream Manipulations 542 14.
11 Stream Manipulations 546 14.12 Stream Manipulations 548 14.13 Creating a Stream from a File 558 14.14 Streams of Random Values 561 14.15 Infinite Streams 562 14.16 Additional Notes on Interfaces 564 14.17 Wrap-Up 564 Chapter 15: JavaFX Graphical User Interfaces: Part 1 567 15.1 Introduction 568 15.
2 JavaFX Scene Builder 569 15.3 JavaFX Application Window Structure 570 15.4 Welcome Application: Displaying Text and an Image 571 15.5 Tip Calculator Application: Intro to Event Handling 577 15.6 Features Covered in the Other JavaFX Chapters 594 15.7 Wrap-Up 594 Chapter 16: JavaFX GUI: Pa.