What changed in Java 13

Text blocks and switch expressions, both in preview

Mostly a staging release: two features people wanted were previewed here and finalised in 14 and 15. Useful mainly as an illustration of how the preview process works.

Released 2019-09 · 1 features · 2 questions · 0 scenarios

Features

Text blocks (preview)

previewJEP 355

The first preview of triple-quoted multi-line string literals, which became standard in 15.

The problem it solved

Multi-line strings needed concatenation and escaped quotes, making embedded SQL, JSON and HTML unreadable.

How you did it before

Concatenation with explicit \n, or loading text from a resource file to avoid the escaping entirely.

Journey: Preview in 13 and 14, standard in 15 (JEP 378).

Asked as

  • Why do features arrive as previews rather than finished?
  • What problem do text blocks solve, and what are the traps?

    Other versions