Modern Java in Action
Modern Java in Action
Summary:
Introduction
The book "Modern Java in Action" (original title Modern Java in Action) is the second, completely revised edition of the cult book Java 8 in Action. The authors — Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft — are renowned experts in the Java world, members of the lambda expressions specification group (JSR 335), and authors of a popular online course on the Coursera platform. The book was published in 2018 and covers Java versions 8, 9, 10, and 11, focusing on modern paradigms: functional and reactive programming.
This is not another syntax reference. It is a practical guide that teaches you to think differently: use lambdas, streams, Optional, CompletableFuture, and reactive streams to write cleaner, more concise, and more performant code. The book is ideal for those already familiar with Java basics (e.g., having read Head First Java or Java: The Complete Reference) but who want to move to the next level and master modern language tools.
What the book is about
The book is divided into five parts, each dedicated to a key topic:
- Part I. Fundamentals — a brief introduction to lambda expressions, functional interfaces, method references, and data streams (Streams). This lays the foundation for further study.
- Part II. Functional Programming — a deep dive into streams: creation, filtering, mapping, reduction, parallel streams. The
Optionalclass is considered separately as an alternative tonull. - Part III. Effective Java Programming — practical tips on refactoring code using lambdas, testing, debugging, and working with dates and times (Java 8 Date/Time API).
- Part IV. Concurrent and Asynchronous Programming —
CompletableFuturefor asynchronous computations,FlowAPI (Reactive Streams), and practical examples of building reactive systems. - Part V. New Features in Java 9, 10, 11 — the module system (Project Jigsaw), syntax improvements (
var, enhancedtry-with-resources), HTTP client, and other innovations.
Who this book is for
The book is aimed at intermediate and advanced Java developers who already write in Java but feel their code is outdated. If you are using Java 7 or an earlier version and want to transition to modern standards, this is your textbook. The book will also be useful for those switching from other languages (e.g., C# or Python) and wanting to quickly master idiomatic Java code.
What the reader will learn
- Write concise code using lambda expressions and method references.
- Efficiently process collections using the Stream API: filtering, sorting, grouping, parallel processing.
- Avoid
NullPointerExceptionwithOptional. - Build asynchronous chains of operations with
CompletableFuture. - Apply reactive streams (Reactive Streams) for processing large volumes of data.
- Use the Java 9 module system to organize large projects.
- Apply new features of Java 10 and 11: local variable type inference (
var), improved HTTP client, new methods in the standard library.
Strengths
The main advantage of the book is its practical focus. Each chapter contains numerous code examples that can be immediately applied in practice. The authors do not just list new features but explain why they are needed and how to use them correctly. The chapters on refactoring are especially valuable: they show how to transform old imperative code into a modern functional style.
Another plus is relevance. Despite the