Core Java for the Impatient, 4th Edition

Book description

Modern Java introduces major enhancements that impact the core Java technologies and APIs at the heart of the Java platform. Many old Java idioms are no longer needed, and new features and programming paradigms can make you far more effective. However, navigating these changes can be challenging.

Core Java for the Impatient, Fourth Edition, is a complete yet concise guide that reflects all changes through Java SE 21, Oracle's latest Long-Term Support (LTS) release. Written by Cay S. Horstmann--author of the classic two-volume Core Java--this indispensable tutorial offers a faster, easier pathway for learning modern Java.

Horstmann covers everything working developers need to know, including the powerful concepts of lambda expressions and streams, modern constructs such as records and sealed classes, and sophisticated concurrent programming techniques. Given the size and scope of Java 21, there's plenty to cover, but it's presented in small chunks organized for quick access and easy understanding, with plenty of practical insights and sample code to help you quickly apply all that's new.

  • Test code as you create it with JShell

  • Improve your object-oriented design with records and sealed classes

  • Effectively use text blocks, switch expressions, and pattern matching

  • Understand functional programming with lambda expressions

  • Streamline and optimize data management with the Streams API

  • Use structured techniques, threadsafe data structures, and virtual threads for effective concurrent programming

  • Work with the modularized Java API and third-party modules

  • Take advantage of API improvements for working with collections, input/output, regular expressions, and processes

Whether you're an experienced developer just getting started with modern Java, or have been programming with Java for years, this guide will help you write more robust, efficient, and secure Java code.

.

Table of contents

  1. About This eBook
  2. Preface
  3. Acknowledgments
  4. 1. Fundamental Programming Structures
    1. 1.1. Our First Program
    2. 1.2. Primitive Types
    3. 1.3. Variables
    4. 1.4. Arithmetic Operations
    5. 1.5. Strings
    6. 1.6. Input and Output
    7. 1.7. Control Flow
    8. 1.8. Arrays and Array Lists
    9. 1.9. Functional Decomposition
    10. Exercises
  5. 2. Object-Oriented Programming
    1. 2.1. Working with Objects
    2. 2.2. Implementing Classes
    3. 2.3. Object Construction
    4. 2.4. Records
    5. 2.5. Static Variables and Methods
    6. 2.6. Packages
    7. 2.7. Nested Classes
    8. 2.8. Documentation Comments
    9. Exercises
  6. 3. Interfaces and Lambda Expressions
    1. 3.1. Interfaces
    2. 3.2. Static, Default, and Private Methods
    3. 3.3. Examples of Interfaces
    4. 3.4. Lambda Expressions
    5. 3.5. Method and Constructor References
    6. 3.6. Processing Lambda Expressions
    7. 3.7. Lambda Expressions and Variable Scope
    8. 3.8. Higher-Order Functions
    9. 3.9. Local and Anonymous Classes
    10. Exercises
  7. 4. Inheritance and Reflection
    1. 4.1. Extending a Class
    2. 4.2. Inheritance Hierarchies
    3. 4.3. Object: The Cosmic Superclass
    4. 4.4. Enumerations
    5. 4.5. Pattern Matching
    6. 4.6. Runtime Type Information and Resources
    7. 4.7. Reflection
    8. Exercises
  8. 5. Exceptions, Assertions, and Logging
    1. 5.1. Exception Handling
    2. 5.2. Assertions
    3. 5.3. Logging
    4. Exercises
  9. 6. Generic Programming
    1. 6.1. Generic Classes
    2. 6.2. Generic Methods
    3. 6.3. Type Bounds
    4. 6.4. Type Variance and Wildcards
    5. 6.5. Generics in the Java Virtual Machine
    6. 6.6. Restrictions on Generics
    7. 6.7. Reflection and Generics
    8. Exercises
  10. 7. Collections
    1. 7.1. An Overview of the Collections Framework
    2. 7.2. Iterators
    3. 7.3. Sets
    4. 7.4. Maps
    5. 7.5. Other Collections
    6. 7.6. Views
    7. Exercises
  11. 8. Streams
    1. 8.1. From Iterating to Stream Operations
    2. 8.2. Stream Creation
    3. 8.3. The filter, map, and flatMap Methods
    4. 8.4. Extracting Substreams and Combining Streams
    5. 8.5. Other Stream Transformations
    6. 8.6. Simple Reductions
    7. 8.7. The Optional Type
    8. 8.8. Collecting Results
    9. 8.9. Collecting into Maps
    10. 8.10. Grouping and Partitioning
    11. 8.11. Downstream Collectors
    12. 8.12. Reduction Operations
    13. 8.13. Primitive Type Streams
    14. 8.14. Parallel Streams
    15. Exercises
  12. 9. Processing Input and Output
    1. 9.1. Input/Output Streams, Readers, and Writers
    2. 9.2. Paths, Files, and Directories
    3. 9.3. HTTP Connections
    4. 9.4. Regular Expressions
    5. 9.5. Serialization
    6. Exercises
  13. 10. Concurrent Programming
    1. 10.1. Concurrent Tasks
    2. 10.2. Thread Safety
    3. 10.3. Threadsafe Data Structures
    4. 10.4. Parallel Algorithms
    5. 10.5. Asynchronous Computations
    6. 10.6. Atomic Counters and Accumulators
    7. 10.7. Locks and Conditions
    8. 10.8. Threads
    9. 10.9. Processes
    10. Exercises
  14. 11. Annotations
    1. 11.1. Using Annotations
    2. 11.2. Defining Annotations
    3. 11.3. Annotations in the Java API
    4. 11.4. Processing Annotations at Runtime
    5. 11.5. Source-Level Annotation Processing
    6. Exercises
  15. 12. The Java Platform Module System
    1. 12.1. The Module Concept
    2. 12.2. Naming Modules
    3. 12.3. The Modular “Hello, World!” Program
    4. 12.4. Requiring Modules
    5. 12.5. Exporting Packages
    6. 12.6. Modules and Reflective Access
    7. 12.7. Modular JARs
    8. 12.8. Automatic Modules
    9. 12.9. The Unnamed Module
    10. 12.10. Command-Line Flags for Migration
    11. 12.11. Transitive and Static Requirements
    12. 12.12. Qualified Exporting and Opening
    13. 12.13. Service Loading
    14. 12.14. Tools for Working with Modules
    15. Exercises
  16. Index

Product information

  • Title: Core Java for the Impatient, 4th Edition
  • Author(s): Cay S. Horstmann
  • Release date: December 2024
  • Publisher(s): Addison-Wesley Professional
  • ISBN: 9780135404522