JAVA 7 vs 8 vs 9 vs 10 vs 11 vs 12 vs 13 vs 14 vs 15 vs 16 vs 17 vs 18 vs 19 vs 20 vs 21

VersionRelease Date
Java 72011
Java 82014
Java 92017
Java 102018
Java 112018
Java 122019
Java 132019
Java 142020
Java 152020
Java 162021
Java 172021
Java 182022
Java 192022

Note – The latest stable release of Java is Java 17. Java 17 was released on September 17, 2021 and is the latest long-term support (LTS) release.

Java 18, 19 are also available, but these releases are not long-term support releases and are intended for early adopters and developers who want to try out new features and APIs.

JAVA 20 and JAVA 21 – See last line of this page-

Java 7 (released in 2011)

FeatureJava 7Prior to Java 7
Binary literalsint binary = 0b10101010;Not supported
Improved type inferenceMap<String, List<Integer>> map = new HashMap<>();Map<String, List<Integer>> map = new HashMap<String, List<Integer>>();
Multiple exception handling`try {…} catch (IOException |SQLException ex) {…}`NA
Automatic resource managementtry (BufferedReader br = new BufferedReader(new FileReader("file.txt"))) {...} catch (IOException ex) {...}BufferedReader br = new BufferedReader(new FileReader("file.txt")); try {...} finally {br.close();}

Java 8 (released in 2014)

1- In Java, you can use lambda expressions to create implementation of functional interfaces. A functional interface is an interface with a single abstract method. Here is an example of a lambda expression in Java:

// Functional interface
interface MultiInter {
  int multiply(int x, int y);

public class Main {
  public static void main(String[] args) {
    // Lambda expression to multiply two numbers
    MultiInter multi = (int x, int y) -> x * y;
    // Call the lambda function
    int result = multi.multiply(4, 5);
    System.out.println(result);  // Output: 20

In this example, the functional interface MultiInter has a single abstract method multiply that takes two int arguments and returns an int. The lambda expression (int x, int y) -> x * y implements this abstract method and defines the logic for multiplying two numbers. The lambda expression is assigned to the functional interface MultiInter , and the lambda function can be called by calling the multiply method on the interface.

2- Stream API: The Stream API is a set of methods that allow you to perform operations on collections of data in a functional style. For example, the following code uses the Stream API to find the first even number in a list:

List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5);
Optional<Integer> firstEven =
.filter(x -> x % 2 == 0)
System.out.println(firstEven.get()); // prints 2

3- In Java, a method reference is a way to refer to a method without actually invoking it. Method references can be used to pass methods as arguments to other methods, or to construct new functions from existing methods.

Here is an example of a method reference in Java 8:

import java.util.Arrays;
import java.util.List;

public class MethodReferenceExample {
public static void main(String[] args) {
List<String> strings = Arrays.asList("a", "b", "c", "d");

// Use a lambda expression to print all elements in the list
strings.forEach(s -> System.out.println(s));

// Use a method reference to print all elements in the list

In this example, the forEach method of the List interface takes a lambda expression as an argument. The lambda expression specifies that for each element in the list, it should be printed to the console. The second call to forEach uses a method reference to the println method of the System.out object instead of a lambda expression.

Both of these calls to forEach will have the same effect, printing all elements of the strings list to the console.

FeatureJava 8 Prior to Java 8
Lambda expressions(x, y) -> x + yN/A
Method referencesSystem.out::printlnN/A
Default methodsdefault void foo() {…}N/A
New Date and Time APILocalDate date =
LocalDate.of(2020, Month.JANUARY, 1);
Calendar cal = Calendar.getInstance(); cal.set(2020, 0, 1); Date date = cal.getTime();
Base64 EncodingBase64.getEncoder().
Stream -> s.length() > 3).forEach(System.out::println);N/A

Java 9 (released in 2017)

FeatureJava 9Prior to Java 9
Private methods in interfacesprivate void foo() {}N/A
Enhanced try-with-resourcestry (resource) {}try {} finally {}
Factory methods for ImmutableList, etc.List.of(1, 2, 3)Arrays.asList(1, 2, 3)
Collection.toArray(IntFunction)list.toArray(String[]::new)list.toArray(new String[list.size()])
jshell – The Java ShelljshellN/A
HTTP/2 ClientHttpClient client = HttpClient.newHttpClient();N/A
Modules (Project Jigsaw)module {}N/A

Java 10 (released in 2018)

FeatureJava 10Prior to Java 10
Local-variable type inferencevar num = 10;int num = (int) 10;
var in lambda expressions(var x, var y) -> x + y(Integer x, Integer y) -> x + y
HTTP Clientvar client = HttpClient.newHttpClient();HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();

Java 11 (released in September 2018)

FeatureJava 11Prior to Java 11
Local variable typevar list = new ArrayList<String>();ArrayList<String> list = new ArrayList<String>();
HTTP ClientHttpClient client = HttpClient.newHttpClient();URL url = new URL(“;); HttpURLConnection con = (HttpURLConnection) url.openConnection();
File handlingString content = Files.readString(Paths.get(“file.txt”));BufferedReader reader = new BufferedReader(new FileReader(“file.txt”)); String line; while ((line = reader.readLine()) != null) { … } reader.close();
Single-line ifif (bool) foo(); else bar();if (bool) { foo(); } else { bar(); }
Single-line forfor (int i : List.of(1, 2, 3)) foo(i);for (int i : new int[] {1, 2, 3}) { foo(i); }

Java 12 (released in March 2019)

FeatureJava 12Prior to Java 12
Switch expressionsswitch (day) { case MONDAY: return “Monday”; case TUESDAY: return “Tuesday”; default: return “Other day”; }if (day == MONDAY) return “Monday”; else if (day == TUESDAY) return “Tuesday”; else return “Other day”;
Text blocksString html = “”” <html> <body> <p>Hello, World</p> </body> </html> “””;String html = “<html>\n” + ” <body>\n” + ” <p>Hello, World</p>\n” + ” </body>\n” + “</html>\n”;
Additional Unicode language supportSystem.out.println(“\uD83D\uDE02”);System.out.println(“😂”);

Java 13 (released in September 2019)

FeatureJava 13Prior to Java 13
Dynamic CDS archivesjava -XX:ArchiveClassesAtExit=myarchive.jsaN/A
Creates a class data-sharing (CDS) archive at JVM exit for faster startup in future JVM runs
ZGC on macOSjava -XX:+UseZGCN/A
Enables the Z Garbage Collector (ZGC) on macOS
Reimplementation of legacy DatagramSocket
Replaces the legacy implementation with a new implementation in the package
Improved AARCH64 intrinsicsjava -XX:+UseAARCH64IntrinsicsN/A
Enables intrinsic functions for the AARCH64 architecture to improve performance
Epsilon garbage collectorjava -XX:+UseEpsilonGCN/A
Enables the Epsilon garbage collector, which does not perform any actual memory reclamation and is intended for testing and benchmarking purposes

Java 14 (released in March 2020)

FeatureJava 14Prior to Java 14
Record classesrecord Point(int x, int y) {}N/A
Pattern matching for instanceofif (obj instanceof Point p) {}if (obj instanceof Point) { Point p = (Point) obj; }
Helpful NullPointerExceptionsNullPointerException.getMessage()N/A

Java 15 (released in September 2020)

FeatureJava 15Prior to Java 15
Sealed classessealed class Shape permits Circle, Rectangle {}N/A
Pattern matching for instanceofif (obj instanceof Point p) {}if (obj instanceof Point) { Point p = (Point) obj; }

Java 16 (released in March 2021)

FeatureJava 16Prior to Java 16
Records (Preview)record Point(int x, int y) {}N/A
Packaging tooljpackageN/A
Second Preview of Foreign-Memory Access APIjava.lang.System.memory()N/A

Java 17 (released in September 2021)

FeatureJava 17Prior to Java 17
Yield in switch statementswitch (day) { case MONDAY: yield TUESDAY; case FRIDAY: yield SUNDAY; }N/A
Records (preview)record Point(int x, int y) {}N/A
Sealed classes (preview)sealed interface Shape permits Circle, Rectangle {}N/A
Enhanced enumsenum Color { RED(“#FF0000”), GREEN(“#00FF00”), BLUE(“#0000FF”) }enum Color { RED(“#FF0000”), GREEN(“#00FF00”), BLUE(“#0000FF”); private String code; Color(String code) { this.code = code; } }

Java 18 (released in March 2022)

FeatureJava 18Prior to Java 18
Recordsrecord Point(int x, int y) {}N/A
Point p = new Point(1, 2);N/A
Sealed Typessealed interface Shape permits Circle, Square {}N/A
final class Circle implements Shape {}N/A
final class Square implements Shape {}N/A
Pattern Matching for instanceof (Preview)if (obj instanceof String s) {N/A
// s has type StringN/A
Foreign-Memory Access (Incubating)try (MemorySegment segment = MemorySegment.allocateNative(100)) {N/A
// Use the memory segmentN/A

Java 19 (released in September 2022)

  • Records:
    • In Java 19, records have been further improved with the ability to specify custom “deep copy” methods, which are used to create a new instance of the record with copies of its components.
    Copy coderecord Point(double x, double y) { public Point { if (x < 0 || y < 0) { throw new IllegalArgumentException("Coordinates must be non-negative"); } } // Custom deep copy method public Point copy() { return new Point(x, y); } }
  • Enhanced Enums:
    • Java 19 introduces several new features for enums, including the ability to use the record keyword to define an enum with record components, and the ability to use the sealed keyword to restrict the inheritance of an enum.
    Copy codesealed interface Shape permits Circle, Rectangle { } record Circle(double radius) implements Shape { } record Rectangle(double width, double height) implements Shape { }

JAVA 20 and JAVA 21 – Going to be released in March 2023 and September 2023 respectively, Stay tuned!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.