Since Java switch from a (kind of) 3-years feature release cycle to 6 months, it is hard for me to track the most important changes. This cheat-sheet shall help me to quickly pick the right Java version. For an extensive list see e.g. Wikipedia.

This lists just the most important changes (from my point of view):

Java 12 (2019)

  • Switch expressions (preview)
    String result = switch (new Random().nextInt(3)) {
        case 0 -> "zero";
        case 1 -> "one";
        case 2 -> "two";
        default -> "impossible";
    };
  • Microbenchmark suite

Exhaustive feature list. See also Java 12: New Features

Java 11 (2018 - LTS)

  • HTTP Client API (now standard)
  • Launch single-file programs without explicit compilation: java HelloWorld.java
  • Launch single-file programs with shebang (note that the file must not end with “.java”):
    #!/usr/bin/java --source 11
    public class HelloWorld {
      public static void main(String[] args) {
        System.out.println("Hello World");
      }
    }
  • Removal of JavaEE packages: JAX-WS, JAXB, JAF, JTA, Common annotations (@Resource…)
  • Removal of CORBA
  • Removal of JavaFX

Exhaustive feature list

Java 10 (2018)

  • Local variable type inference - the var keyword
  • Docker container awareness (for calculating memory and CPU resources)

Exhaustive feature list. See also What’s new in Java 10, Guide to Java 10.

Java 9 (2017)

  • Java modules (aka Project Jigsaw)
  • HTTP Client API (incubation)
  • Process API
  • Private methods in interfaces
  • JShell (read-evaluate-print loop)
  • Multi-release jar files
  • G1 (Garbage First) garbage collector is now default

Exhaustive feature list. See also Java 9 New Features.

Java 8 (2014 - LTS)

  • Lambda expressions, functional interfaces
  • Method references (e.g. String::toUppercase)
  • Stream API
  • Default and static methods on interfaces
  • Optional type
  • DateTime API

Exhaustive feature list. See also Java 9 New Features.

comments powered by Disqus