Member-only story
JAVA 13 Features
This article is about the simple introduction of Java 13 and its new features.
1. JEP-354 Switch Expressions (Preview)
Switch expressions were added (preview) feature in JDK 12. Now we use “yield” to return.(in JDK 12 “break” used for this)
P.S This switch expression becomes a standard feature in Java 14 JEP 361.
Switch Expressions is preview for this:
javac — enable-preview — release 13 Example.java
java — enable-preview Example
The preview feature must also be activated at startup. Of course, build tools (Maven, etc.) also have configuration switches:
java — enable-preview Examples
2. JEP-355 Text Blocks (Preview)
This JEP introduces a multi-line string literal, a text block, finally. (Strings such as embedded JSON, XML, HTML, etc.)
To use it triple-double quotes.
P.S This text blocks is a permanent feature in Java 15.
String JSON_STRING
= “{\r\n” + “\”name\” : \”Fatih\”,\r\n” + “\”like\” : \”JAVA\”\r\n” + “}”;
Now let’s write the same JSON using String text blocks:
String TEXT_BLOCK_JSON = “””
{
“name” : “Fatih”,
“like” : “JAVA”
}
“””;



