What’s New in Java 12?

Introduction

Java started out strong in 2019. On March 19, the Java team shipped the latest major version release, Java 12. If you follow the latest developments in the Java world, you might know that you can expect two major Java releases per year. This is great news for everyone committed to the idea of shipping early and often. Ultimately, you’ll be able to get your hands on new features and bug fixes on a regular basis.

In comparison to the last Long-Term Release (LTS) Java 11, version 12 contains fewer features but also fewer breaking changes. If you haven’t caught up with Java 11 yet, I’d recommend reading the report “What’s New in Java 11?”.

This edition of the report condenses everything you need to know about Java 12 into a few pages to help you determine whether it’s worthwhile to upgrade now or if you should hold off. We begin by introducing the shiny new features. Later, we touch on removals and deprecations and then conclude with a discussion of performance and security enhancements. Let’s get started!

New Features

Let’s explore the new functionality through an example. To test it out, we’ll write some JUnit tests that apply the new APIs and verify the correct behavior for different use cases. We begin by having a look at the latest addition to the Stream API.

Teeing Collectors

Since its introduction in Java 8, the Stream API provides methods for transforming elements in a Stream instance with the help of Collectors. The latest version of ...

Get What's New in Java 12? now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.