Fundamentals 9 min read

Top 5 New Features Expected in Java 14

This article outlines the five major preview features slated for Java 14, including instanceof pattern matching, text blocks with new escape sequences, record types, the incubating jpackage tool, and the deprecation of the ParallelScavenge + SerialOld garbage collector combination.

Architect's Tech Stack
Architect's Tech Stack
Architect's Tech Stack
Top 5 New Features Expected in Java 14

Java 14 is scheduled for release in March 2020, and this article summarizes the five most important preview features that are expected to be included.

1. instanceof Pattern Matching

The new preview feature improves the instanceof operator by allowing pattern matching, which makes type checks and casts more concise and safer.

if (obj instanceof Integer) {
    int intValue = (Integer) obj;
    // ... use intValue ...
}

With pattern matching the same logic can be written more cleanly:

if (x instanceof Integer i) {
    // ... use i as an Integer directly ...
}

A more complex example shows how multiple type patterns can be handled in a single if statement, reducing boilerplate code.

2. Text Blocks (Preview Feature)

Text blocks, introduced as a preview in Java 13 and retained in Java 14, allow multi‑line string literals without the need for explicit newline characters. Two new escape sequences are added: \ to suppress the newline and \s to insert a single space.

String literal = "This is a string splitted " +
                 "in several smaller " +
                 "strings.";

Using a text block with the new escapes, the same string can be written as:

String text = """
                This is a string splitted \
                in several smaller \
                strings.
                """;

Another example demonstrates aligning output using \s :

String colors = """
                red \s
                green\s
                blue \s
                """;

3. Record Types

Records are a preview feature that provide a compact syntax for declaring immutable data carriers. They automatically generate equals , hashCode , and toString implementations.

record Point(int x, int y) { }

The above declaration is equivalent to a traditional class with final fields, a constructor, and the standard methods.

4. jpackage Tool

The packaging tool jpackage , removed before the Java 13 release, returns as an incubating feature in Java 14. It enables developers to create self‑contained Java applications with native installers, supports custom launch parameters, and can be invoked via the command line or the ToolProvider API.

5. Deprecation of ParallelScavenge + SerialOld GC

JEP 366 deprecates the ParallelScavenge + SerialOld garbage‑collector combination because it is rarely used and costly to maintain. The deprecation does not remove the collector but signals that it may be removed in a future release.

Overall, the most exciting preview feature for most developers is the instanceof pattern matching, which paves the way for broader pattern‑matching capabilities in future Java versions.

JavaGarbage CollectionPattern MatchingText BlocksJava14jpackageRecord Types
Architect's Tech Stack
Written by

Architect's Tech Stack

Java backend, microservices, distributed systems, containerized programming, and more.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.