Java 13 was released for General Public usage on 17 September 2019. But, Similar to Java 12, this wasn’t considered a major release too because it didn’t offer much developer-specific features. You can download Java 13 by clicking here.

Java 13 Features

JEP 350:Dynamic CDS Archives
JEP 351:ZGC: Uncommit Unused Memory
JEP 353:Reimplement the Legacy Socket API
JEP 354:Switch Expressions (Preview)
JEP 355:Text Blocks (Preview)
Java 13 Features...!!! Share on X

Check out: JAVA 11 Features with examples

1. JEP 350 – Dynamic CDS Archive

This JEP introduced to extend the class-data sharing feature, introduced in Java 10 to simplify the creation process of CDS archive.

The Objective behind CDS is to improve the startup process by creating the class data archive once and then reuse it. In this way, JVM need not create archive again and again.

2. JEP 351 – ZGC: Uncommit Unused Memory

Z Garbage Collector was introduced in Java 11 as part of JEP-333. It gives a short pause time during clean up the heap memory. But the challenge was that It didn’t return the unused heap memory to the Operating System.

Now, JEP-333 has been enhanced as part of this JEP-351 so that now ZGC returns the unused memory to the Operating System.

3. JEP 353 – Reimplement the Legacy Socket API

The underlying implementation of the java.net.Socket and java.net.ServerSocket APIs are very old and have been enhanced as part of this JEP-353 which introduces a new implementation for Socket API.

Java 13 introduced NioSocketImpl, is a drop-in replacement for PlainSocketImpl.

But, if you want to use the old implementation, you can easily switch by setting jdk.net.usePlainSocketImpl as a system property.

4. JEP 354 – Switch Expressions Enhancements

JEP 354 is an enhancement to the Switch Expression, added as a preview feature in Java 12. It’s not a major change. Almost everything is the same as Java 12 expect a new keyword ‘yield has been added which replaced the break keyword to return the value from the case statement.

Let me show you how it was before Java 12, how it was in Java 12, and now what change has been brought by Java 13 in Switch Statement.

Before Java 12: It was the traditional Switch Statement

In Java 12: ‘break’ can be used to return the value now.

In Java 13: ‘break’ won’t work anymore as it was in Java 12. You need to use ‘yield’ to return the value.

5. JEP 355 – Text Blocks

JEP 355 allows you to create a multiline string or you can say a text-block. You need to write a multiline string inside a pair of triple double-quotes.

Just to keep in mind, the beginning triple double quotes must be followed by a line terminator.

Before Java 13

Output:

In Java 13

Output:

Java 13 Features...!!! Share on X

Other Useful References:

    • What is new in Java 13

Author

  • Deepak Verma

    Deepak Verma is a Test Automation Consultant and Software development Engineer for more than 10 years. His mission is to help you become an In-demand full stack automation tester. He is also the founder of Techndeck, a blog and online coaching platform dedicated to helping you succeed with all the automation basics to advanced testing automation tricks.

    http://Techndeck.com deepak.rkgit@gmail.com Verma Deepak