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)
| Feature | explanation |
|---|
| Lambdas & Functional Interfaces | Introduction of lambda expressions for shorter and more concise code writing as well as functional interfaces to improve code models. |
| Stream API | A new API for processing data in a declarative manner (e.g. filtering, mapping, reducing). Reduces patterns such as loops. |
| Optional Class | Avoiding NullPointerExceptions by representing optional values. |
| Date and Time API | New, more comprehensive and error-resistant Date and Time API based on Joda-Time. |
| Rhino JavaScript Engine | JavaScript engine for the JVM that enables interoperability between Java and JavaScript. |
Java 9 (September 2017)
| Feature | explanation |
|---|
| 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 improvements | Additional methods like takeWhile, dropWhile, and iterate to increase the functionality of streams. |
| Factory Methods for Collections | Introduced static factory methods (List.of, Set.of, Map.of) for convenient and safe initialization of collections. |
Java 10 (March 2018)
| Feature | explanation |
|---|
| Local-Variable Type Inference | Introduced var to automatically infer local variables, making the code more concise and readable. |
Java 11 (September 2018)
| Feature | explanation |
|---|
| New String Methods | Additional methods like isBlank, lines, strip, repeat to edit strings more easily. |
| Lambda Syntax for Anonymous Classes | Enables the use of Lambda for anonymous class implementations. |
| HTTP Client API | Standardized HTTP Client API for sending HTTP requests synchronously and asynchronously. |
Java 12 (March 2019)
| Feature | explanation |
|---|
| Switch Expressions (Preview) | Improved switch expressions that can be used to return values directly, making code more concise. |
Java 13 (September 2019)
| Feature | explanation |
|---|
| Text Blocks (Preview) | Introducing text blocks (""""`) that make it easier to write multi-line string text. |
Java 14 (March 2020)
| Feature | explanation |
|---|
| 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)
| Feature | explanation |
|---|
| Sealed Classes (Preview) | Allows control over class hierarchies by restricting which classes are allowed to extend a class. |
Java 16 (March 2021)
| Feature | explanation |
|---|
| Pattern Matching for instanceof | Simplifies 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)
| Feature | explanation |
|---|
| 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)
| Feature | explanation |
|---|
| Simple Web Server | A simple web server for development purposes. |
Java 19 (September 2022)
| Feature | explanation |
|---|
| Virtual Threads (Preview) | Lightweight threads that enable massively parallel applications to be written efficiently. |
Java 20 (March 2023)
| Feature | explanation |
|---|
| Enhancements to ARM | Improving the architecture for modern ARM processors. |
Java 21 (September 2023)
| Feature | explanation |
|---|
| String Templates (Preview) | Allows expressions to be incorporated into string literals cleanly and safely. |
Java 22 (March 2024)
| Feature | explanation |
|---|
| Vector API (Incubator) | Allows the use of vector operations for numerical calculations. |
Java 23 (September 2024)
| Feature | explanation |
|---|
| Enhanced Primitive Type Patterns | Provides patterns for primitive data types, making it easier to work with these types. |
| Flexible Constructor Bodies | Allows constructors to flexibly initialize instantiated objects. |
| Simplified Module Imports | Simplifies importing and managing modules in projects. |
| Structured Concurrency | Simplifies parallel programming through structured and reliable thread handling. |
| Class File API Update | Improvements 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