DEV Community

shantanu mahakale
shantanu mahakale

Posted on

Quick Recap: Java Versions

Here’s a practical summary of the most useful Java features added from Java 8 to recent versions, focusing on what developers actually use in daily coding.


Java 8 (Most Impactful Release)

  • Lambda Expressions → Functional programming
  • Stream API → Declarative data processing
  • Functional Interfaces (@FunctionalInterface)
  • Default & Static Methods in Interfaces
  • Optional Class – Avoid null checks
  • Date/Time API (java.time) – Replaces old Date/Calendar
  • Method References (:: operator)

👉 Most popular version in production even today.


Java 9

  • Modules (JPMS)module-info.java
  • JShell – REPL for testing code quickly
  • Factory Methods for Collections
List.of(1, 2, 3);
Set.of("A", "B");
Enter fullscreen mode Exit fullscreen mode
  • Improved Stream API: takeWhile(), dropWhile(), iterate()

Java 10

  • Local Variable Type Inference (var)
var name = "Shantanu";
var list = new ArrayList<String>();
Enter fullscreen mode Exit fullscreen mode

👉 Not like JavaScript – only for local vars.


Java 11 (LTS Release)

  • HTTP Client API (modern replacement for HttpURLConnection)
HttpClient client = HttpClient.newHttpClient();
Enter fullscreen mode Exit fullscreen mode
  • String Methods
"hello".isBlank();
"line1\nline2".lines();
"test".repeat(3);
Enter fullscreen mode Exit fullscreen mode
  • var allowed in lambda params

👉 Very stable & widely used enterprise version after Java 8.


Java 14

  • Switch Expressions (Enhanced)
int result = switch(x) {
case 1 -> 100;
case 2 -> 200;
default -> 0;
};
Enter fullscreen mode Exit fullscreen mode
  • Records (Preview) – Lightweight data classes
  • NullPointerException with details

Java 15

  • Text Blocks (Multiline Strings)
String json = """
{
"name": "John"
}
""";
Enter fullscreen mode Exit fullscreen mode

👉 Clean JSON, SQL, HTML formatting.


Java 16

  • Records (Final Release)
public record User(String name, int age) {}
Enter fullscreen mode Exit fullscreen mode
  • Pattern Matching for instanceof
if (obj instanceof String s) {
System.out.println(s.toUpperCase());
}
Enter fullscreen mode Exit fullscreen mode

Java 17 (LTS)

  • Sealed Classes
public sealed class Animal permits Dog, Cat {}
Enter fullscreen mode Exit fullscreen mode
  • Switch pattern matching (Preview)
  • Stronger encapsulation & security updates

👉 Current long-term support (LTS) version used widely in new projects.


Java 19 / 20 (Preview Features)

  • Virtual Threads (Project Loom)
Thread.startVirtualThread(() -> {
// lightweight threads
});
Enter fullscreen mode Exit fullscreen mode

👉 Massive performance boost for high-concurrency apps.

  • Structured Concurrency Better control over multi-threading workflows.

Java 21 (LTS – Most Recent Major)

  • Virtual Threads (Final) – Game changer for performance
  • String Templates (Preview)
STR."Hello, ${name}!"
Enter fullscreen mode Exit fullscreen mode
  • Sequenced Collections – Ordered access to elements
  • Record Patterns – Destructuring syntax
  • Pattern Matching Enhancements

👉 Consider upgrading if starting a new application.


Summary Table

Version Key Features
Java 8 Lambdas, Streams, Optional, Date API
Java 9 Modules, JShell
Java 10 var keyword
Java 11 HTTP Client API, String methods
Java 14 Switch expressions, Records (preview)
Java 15 Text Blocks
Java 16 Records, Pattern Matching
Java 17 LTS, Sealed Classes
Java 19/20 Virtual Threads (preview)
Java 21 Virtual Threads (final), String templates

Top comments (0)