DEV Community

Code Green
Code Green

Posted on

Java 8 vs Java 11 vs Java 17 Comparison and Key Features

Comparison of Key Features in Java 8, 11, and 17

Feature Java 8 Java 11 Java 17
Lambda Expressions Introduced lambda expressions for functional programming. No new changes; continued support. No new changes; continued support.
Stream API Added Stream API for processing sequences of elements. No new changes; continued support. No new changes; continued support.
Optional Class Introduced Optional to avoid null references. No new changes; continued support. No new changes; continued support.
Default Methods in Interfaces Allowed interfaces to have default methods. No new changes; continued support. No new changes; continued support.
New Date and Time API Introduced java.time package. No new changes; continued support. No new changes; continued support.
Nashorn JavaScript Engine Introduced Nashorn for executing JavaScript. Deprecated in later versions. Removed Nashorn.
Garbage Collection G1 Garbage Collector became the default. Improved G1 GC, better performance. Further improvements in G1 GC and new garbage collection options.
HTTP Client API Not included. Introduced a new HttpClient API. Continued support and enhancements.
String Methods New methods like String.join() added. No new changes; continued support. New methods such as String.repeat(), String.lines(), and String.strip().
Local-Variable Type Inference Not included. Introduced var for local variable type inference. Continued support for var.
Flight Recorder Not available. Introduced as an open-source feature. Continued support with enhancements.
Sealed Classes Not included. Not included. Introduced sealed classes for more control over inheritance.
Pattern Matching for instanceof Not included. Not included. Introduced for cleaner type checks.
Enhanced Switch Expressions Not included. Not included. Introduced enhanced switch expressions for simpler syntax.
Deprecation of Applet API Not included. Deprecated the Applet API. Continued deprecation; Applet API removed in future versions.

Top comments (1)

Collapse
 
khmarbaise profile image
Karl Heinz Marbaise

The flight recorder has been available also in JDK8 (docs.oracle.com/en/java/java-compo...)

The "var" (local type inference) has been introduced in JDK 10 (openjdk.org/projects/jdk/10/) and not in JDK 11.

For changes in the API I strongly recommend to check: javaalmanac.io/jdk/11/apidiff/8/ (from 8 to 11) and javaalmanac.io/jdk/17/apidiff/11/ (from 11 to 17)...

In JDK 10:

  • toUnmodifiableList
  • toUnmodifiableSet
  • toUnmodifiableMap in JDK 12:
  • teeing in JDK 16:
  • mapMulti
  • mapMultiToInt
  • mapMultiToLong
  • mapMultiToDouble
    Just to mention a few...

  • String.repeat, String.lines, String.strip have been introduced in JDK 11 and not in JDK 17...

  • (javaalmanac.io/jdk/11/apidiff/8/)

  • String.transform (JDK12)

  • String.stripIndent,String.translateEscapes,String.formatted in JDK 15,