Java 11 New Features: Garbage Collector Upgrades

Java 11 introduced numerous new features, some of the most significant being:

  1. HTTP Client API: Java 11 introduces a new HTTP client API that enables developers to send HTTP requests and receive responses more easily. This API supports asynchronous request and response processing, as well as streaming requests and response bodies.
  2. Epsilon Garbage Collector: Java 11 introduces a new experimental garbage collector called the Epsilon Garbage Collector. It is a no-op garbage collector that helps developers better understand the memory usage of their applications.
  3. ZGC Garbage Collector: Java 11 introduces a new experimental garbage collector known as the ZGC (Z Garbage Collector). It is a low-latency garbage collector capable of handling very large heap sizes while maintaining extremely short pause times.
  4. Enhanced Strings: Java 11 introduces several new methods and features that make strings easier to use and understand. These enhancements include methods such as strip(), repeat(), and lines().
  5. Extension of the var Keyword: The usage scope of the var keyword is extended in Java 11; it can now be used within lambda expressions, try-with-resources statements, and method references.
  6. Local Variable Syntax for Lambda Expressions: Java 11 introduces a new syntax that allows the use of the var keyword to declare local variables within lambda expressions.
// Example demonstrating the use of var in a lambda expression
List<String> names = Arrays.asList("Alice", "Bob");
names.forEach(name -> System.out.println(name));