Java 10 and Java 11 features
Java 10 Features (Released March 2018)
Java 10 was a short-term release but introduced some useful enhancements:
- Local Variable Type Inference (
var
)- Enables you to declare local variables without explicitly specifying the type.
- Example:
var name = "Java"; var list = List.of(1, 2, 3);
- Improves code readability and reduces verbosity.
- Garbage Collector (GC) Improvements
- Introduced G1 Garbage Collector optimizations for better performance.
- Allowed parallel processing during memory reclamation.
- Application Class-Data Sharing
- Reduces startup time and memory footprint by sharing class metadata between applications.
- Thread-Local Handshakes
- Improves how threads interact, allowing faster execution for small tasks.
Java 11 Features (Released September 2018)
Java 11 was a long-term support (LTS) release, meaning it receives updates for a longer duration. It introduced several key improvements:
- New HTTP Client API (Finalized)
- Initially introduced in Java 9, now officially part of the standard API.
- Supports modern web protocols, including HTTP/2 and WebSockets.
- String API Enhancements
- New useful methods such as:
" Java ".strip(); // Removes whitespace "hello".repeat(3); // Outputs: hellohellohello
- Improves efficiency in handling text operations.
- New useful methods such as:
- Lambda Parameter
var
Support- Allows using
var
inside lambda expressions:(var x, var y) -> x + y;
- Allows using
- Removal of Java EE and CORBA Modules
- Simplifies the Java runtime by removing outdated technologies.
- Launch Single-File Programs Without Compilation
- Run a
.java
file directly without compiling:java HelloWorld.java
- Run a
Java 11 brought valuable updates, especially for enterprise applications due to its LTS status.