Java 12 New Features
Java SE 12 was released in March 2019. The full list of new features in JDK 12 can be found here: https://openjdk.org/projects/jdk/12/ In this tutorial, we will look at some of these new features and examine some of them. 1. JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental) Shenandoah is a new garbage collection (GC) algorithm which reduces GC pause times, independent of heap size. This GC algorithm is experimental so in order to use it with Java 12, you have to enable it : -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC 2. JEP 325: Switch Expressions (Preview) This JEP extends the switch statement to be used as either a statement or an expression. Meaning that we can now return a value from a switch expression. Before Java 12, we can return a value by assigning it to a variable: String getColor(int num) { String result = ""; switch (number) { case 1, 2, 3: result = "red, green or blue"; break;