Java still used for many digital product companies even today. Currently, Java is on version 13. Today I want to show how to use JDK13 with Gradle6. JDK13 has some improvements on GC(as usual), minor new methods for Strings and IO and there are 2 interesting new Experimental Features. So let’s get started.
Let’s take a look at the build.gradle file.
Besides using the Java plugin. We need to set the source code compatibility and target to 13. We also need to pass additional parameters for compile, testing and running in order to enable experimental features. Now we can go to the new Experimental features in Java 13.
Java 13 Code
So here we have 2 features. First, we have a multi-line string with “”” and then we can pass a Json object without annoying scaping “\” like we had to do it before. The other cool feature is that we can use switch statements directly in a variable which makes the switch more similar to a pattern matcher.
Here is the complete code on my GitHub.
Originally published at http://diego-pacheco.blogspot.com on February 6, 2020.