[EN] Beyond Java 8

Julian | Sep 25, 2024 min read

Beyond Java 8 - What’s next?

After I’ve been working with Java 8 for some time now due to customer projects. It’s time to see what features I’m missing. Here is a summary of the most important features since Java 8.

Java 8 (March 2014)

Featureexplanation
Lambdas & Functional InterfacesIntroduction of lambda expressions for shorter and more concise code writing as well as functional interfaces to improve code models.
Stream APIA new API for processing data in a declarative manner (e.g. filtering, mapping, reducing). Reduces patterns such as loops.
Optional ClassAvoiding NullPointerExceptions by representing optional values.
Date and Time APINew, more comprehensive and error-resistant Date and Time API based on Joda-Time.
Rhino JavaScript EngineJavaScript engine for the JVM that enables interoperability between Java and JavaScript.

Java 9 (September 2017)

Featureexplanation
Project Jigsaw (Module System)Enables application modularization for better maintainability and security. Module-info.java for defining modules.
JShell (REPL)Interactive command line for quick testing and experimentation with Java code.
Stream API improvementsAdditional methods like takeWhile, dropWhile, and iterate to increase the functionality of streams.
Factory Methods for CollectionsIntroduced static factory methods (List.of, Set.of, Map.of) for convenient and safe initialization of collections.

Java 10 (March 2018)

Featureexplanation
Local-Variable Type InferenceIntroduced var to automatically infer local variables, making the code more concise and readable.

Java 11 (September 2018)

Featureexplanation
New String MethodsAdditional methods like isBlank, lines, strip, repeat to edit strings more easily.
Lambda Syntax for Anonymous ClassesEnables the use of Lambda for anonymous class implementations.
HTTP Client APIStandardized HTTP Client API for sending HTTP requests synchronously and asynchronously.

Java 12 (March 2019)

Featureexplanation
Switch Expressions (Preview)Improved switch expressions that can be used to return values ​​directly, making code more concise.

Java 13 (September 2019)

Featureexplanation
Text Blocks (Preview)Introducing text blocks (""""`) that make it easier to write multi-line string text.

Java 14 (March 2020)

Featureexplanation
Switch Expressions (Final)Switch expressions become final, providing a more concise and expressive way to use switch statements.
Records (Preview)A new type of class that only carries data and requires no additional code (Data Carrier).

Java 15 (September 2020)

Featureexplanation
Sealed Classes (Preview)Allows control over class hierarchies by restricting which classes are allowed to extend a class.

Java 16 (March 2021)

Featureexplanation
Pattern Matching for instanceofSimplifies casting and usage of object types through pattern matching on instanceof.
Records (Final)Records become final and provide an easy way to define classes for immutable data.

Java 17 (September 2021)

Featureexplanation
Sealed Classes (Final)Sealed classes become final and allow tight class interfaces to be defined.
Pattern Matching for switch (Preview)Allows the use of patterns within switch statements.

Java 18 (March 2022)

Featureexplanation
Simple Web ServerA simple web server for development purposes.

Java 19 (September 2022)

Featureexplanation
Virtual Threads (Preview)Lightweight threads that enable massively parallel applications to be written efficiently.

Java 20 (March 2023)

Featureexplanation
Enhancements to ARMImproving the architecture for modern ARM processors.

Java 21 (September 2023)

Featureexplanation
String Templates (Preview)Allows expressions to be incorporated into string literals cleanly and safely.

Java 22 (March 2024)

Featureexplanation
Vector API (Incubator)Allows the use of vector operations for numerical calculations.

Java 23 (September 2024)

Featureexplanation
Enhanced Primitive Type PatternsProvides patterns for primitive data types, making it easier to work with these types.
Flexible Constructor BodiesAllows constructors to flexibly initialize instantiated objects.
Simplified Module ImportsSimplifies importing and managing modules in projects.
Structured ConcurrencySimplifies parallel programming through structured and reliable thread handling.
Class File API UpdateImprovements to the API for reading and writing Java class files.

This compilation focuses on the key innovations and changes in each Java version that are most important to developers. Each of these features provides significant improvements to the writing, readability, efficiency, and functionality of Java programs.

You can find code examples here