{{announcement.body}}
{{announcement.title}}
Refcard #318

Java 13

A Java expert goes over everything Java developers need to know about the new JDK 13, walking through code examples to illustrate these new updates and the benefits they bring.

7,835

Brought to you by

Azul Systems
Free .PDF for easy Reference

Written by

Simon Ritter Deputy CTO, Azul Systems
Refcard #318

Java 13

A Java expert goes over everything Java developers need to know about the new JDK 13, walking through code examples to illustrate these new updates and the benefits they bring.

7,835
Free .PDF for easy Reference

Written by

Simon Ritter Deputy CTO, Azul Systems

Brought to you by

Azul Systems
Table of Contents

Introduction

Section 1

Introduction

We are now well into the new six-month release cadence of the JDK and, with the release of JDK 13, it is clearly working well.

One thing that is obvious is that, whilst the overall rate of change for the Java platform has increased, individual releases will have fewer new features. This is the case with JDK 13, which includes only five JDK Enhancement Proposals (JEPs) and 76 new core library elements (of which nearly half are simple additions to the java.io package).

Note: This is correct as of August 18, 2019, since JDK 13 has not yet been released.

Let's start with a change to the language syntax, in the form of text blocks (JEP 355). Java has always suffered a little from the way strings are defined. A string starts with a double-quote and ends with a dou- ble-quote, which is fine, except that the string cannot span more than one line. This leads to workarounds, like including \n where line breaks are required or concatenating strings and newlines, but these do not lend themselves to clear code. In JDK 12, there was a proposal for raw-string literals (JEP 326), but the feedback from the early access builds of the JDK was such that the decision was made to remove it before release.

Text blocks are a different solution to the same challenge. A text block starts with a triple double-quote and is terminated with the same. Anything between them is interpreted as a part of the string, including new lines. There is nothing magical about the end result, which is still a normal java.lang.String object. Text blocks can be used anywhere that a string literal can be used in Java with no difference to the compiled code.

This is a preview of the Java 13 Refcard. To read the entire Refcard, please download the PDF from the link above.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}