About This Title

Pages: 232
Published: May 2025
ISBN: 9781680509816
In Print

Skill Level Meter

Cruising Along with Java

Modernize and Modularize with the Latest Features

by Venkat Subramaniam

Java is on a fast-paced development schedule that brings with it improved design capabilities and enhancements for application security. Learn about the changes to Java, from version 9 to 24, and apply new features to build enterprise applications faster and with fewer errors. Get up to speed on how to make your code concise, expressive, and less error prone, and create better OO programs with the newest features. Modularize and create applications with ease and enhanced security and dependency management. This book contains twelve chapters that dive deep into the features, using plenty of examples for you to practice along with.

eBook Formats:

  • PDF for desktop/tablets

  • epub for Apple Books, e-readers

  • mobi for Kindle readers

Get all eBook formats here for $26.95 (USD)

Add to Cart we accept visa, mastercard, amex, discover, paypal


Paperback Formats:

Please support indie bookstores!
Find indie bookstores in the U.S. Find indie bookstores around the world.


Java is changing quickly—don’t be left behind. This book will keep you up to date on the amazing capabilities of the Java language introduced between versions 9 and 24. Whether you are using Java 8 or one of the newer versions of Java, this book will serve as your practical guide to explore and apply the features in these versions of Java.

Learn to properly use type inference and avoid its pitfalls. Use text blocks to write elegant multiline strings and embed XML and JSON documents in code. Design better OO code with records and sealed classes, and along the way, learn proper ways to apply these new ideas. Reduce verbosity and hidden errors in code using switch expressions and pattern matching syntax. Use gatherers to extend your functional pipeline with custom steps. Take your upgrade journey further by modularizing your Java code, to make it more secure and manage dependencies clearly. Leverage those capabilities to more easily and dynamically discover services.

Don’t tolerate clumsy old Java code; instead, benefit from the significant changes to the language in versions 9 through 24.

What You Need

To make use of all the features in this book, you’ll need at least Java 24.

Resources

Releases:

2025/05/20
P1.0
First printing.
2025/04/07
B8.0
Production is complete. Now it’s on to layout and the printer.
2025/02/11
B7.0
The book is content-complete and headed to production.
2024/11/22
B6.0
*Added the last chapter Chapter 12, Creating Custom Gatherers, on page 181. In this chapter we look at the different types of custom gatherers we can create, dive deep into creating our own gatherers, and discuss when to create each type of gatherer. *Added a section Pattern Matching Primitive Types, on page 109. This new section focuses on the nuances of pattern matching with primitive types and discusses the intricacies of how the type matching is resolved. *If you read earlier versions of this beta book you’ll notice we have changed the last part of it from the topic of asynchronous programming to gatherers. From the time we set out on this book project to where we are now, we have learned a few things. First, the topic of asynchronous programming is too big to do justice in two short chapters. We have decided to write an entire book on that topic instead of squeezing it in this book. Second, some of the APIs related to asynchronous programming are still in preview feature and, if we decided to include those in this book, we will have to delay this book further. *The concept of gatherers, which emerged since we started working on this book, is a good replacement, and a perfect fit for the main theme of this book. *We hope you like the change. If you’re interested in asynchronous programming in Java, please look forward to a new book on that topic coming soon.

Contents & Extracts

Preface

  • The Evolution of Java excerpt
  • Syntax Sugar
    • Using Type Inference
      • Type Inference and Java
      • Generics and Type Witness
      • Diamond Operator Enhancements
      • Lambda Expressions Parameters Type Inference
      • Local Variable Type Inference
      • Using Type Inference with for and try
      • var: Not a Type nor a Keyword
      • Targeted Intersection Types
      • Extent of Type Inference
      • Mind the Inference
      • Wrapping Up
    • Reducing Clutter with Text Blocks excerpt
      • From Noisy to Nice
      • Embedding Strings
      • Smart Indentations
      • Trailing Spaces and Special Escapes
      • Creating XML Documents Using Text Blocks
      • Creating JSON Output Using Text Blocks
      • Wrapping Up
  • Design Aid
    • Programming with Records
      • From Verbose to Succinct
      • Components, Fields, Getters, and Metadata
      • Extent of Immutability
      • Built-in Methods
      • Implementing Interfaces
      • Restrictions for the Greater Good
      • Considering a Custom Canonical Constructor?
      • Preferring the Compact Constructor
      • Creating a Custom Noncanonical Constructor
      • (Local) Records as Tuples
      • Wrapping Up
    • Designing with Sealed Classes and Interfaces
      • Need for a Closed Hierarchy
      • Using sealed
      • Sealed Related Metadata
      • Using the permits Clause
      • Constraints on the Subclasses
      • Wrapping Up
  • Fluent Expressions
    • Switching to Switch Expression excerpt
      • From Statements to Expressions
      • Using Multiple Labels in a Case
      • Cases with Non-expressions
      • Completeness of a switch Expression
      • Wrapping Up
    • Using Powerful Pattern Matching
      • Pattern Matching with instanceof
      • Using Type Matching
      • Matching null
      • Guarded Patterns
      • Dominance Check
      • Completeness Check
      • Completeness Check and Sealed Classes/Interfaces
      • Deciding to Use default or Not
      • Pattern Matching Primitive Types
      • Destructuring Records When Pattern Matching
      • Type Inference with Destructuring Records
      • Unnamed Variables in Pattern Matching
      • Wrapping Up
  • Modularization
    • Modularizing Your Java Applications
      • Maven, Gradle, and Modularization
      • Modules and the Benefits of Modularization
      • Modularized Java
      • Starting with a Legacy Application
      • Perils of the Existing Design
      • Modularizing the Space Station Application
      • Architectural Constraints Promoted by Modules
      • Wrapping Up
    • Working with Modules
      • Exploring the Module Metadata
      • Defining APIs in a Modular Way
      • Targeted Linking Using jlink
      • Wrapping Up
    • Creating Plug-ins with ServiceLoader
      • The Plug-in Architecture
      • Defining a Specification Module
      • Creating a Client Module
      • Implementing a Plug-in
      • Implementing Additional Plug-ins
      • Reloading the Implementations
      • Functional Style Iteration
      • Wrapping Up
  • Custom Functional Pipeline Steps
    • Extending Functional Pipelines with Gatherers
      • Why Do We Need Gatherers?
      • Creating Custom Steps Using the gather() Method
      • Using Built-in Gatherers
      • Wrapping Up
    • Creating Custom Gatherers
      • The Machinery Behind the gather() Method
      • Flavors of Gatherers
      • Creating Sequential Stateless Gatherers
      • Creating Sequential Stateful Gatherers
      • Creating Parallelizable Stateless Gatherers
      • Creating Parallelizable Stateful Gatherers
      • Wrapping Up

Author

Dr. Venkat Subramaniam is an award-winning author, founder of Agile Developer, Inc., and an instructional professor at the University of Houston. He has trained and mentored thousands of software developers in the US, Canada, Europe, and Asia, and is regularly invited to speak at international conferences. He’s the (co)author of multiple books, including the 2007 Jolt Productivity award winning book Practices of an Agile Developer.

eBook Formats:

  • PDF for desktop/tablets

  • epub for Apple Books, e-readers

  • mobi for Kindle readers

Get all eBook formats here for $26.95 (USD)

Add to Cart we accept visa, mastercard, amex, discover, paypal


Paperback Formats:

Please support indie bookstores!
Find indie bookstores in the U.S. Find indie bookstores around the world.

Related Titles:

Skill Level Meter

About This Title

Pages: 232
Published: May 2025
ISBN: 9781680509816
Edition: 1
In Print