Java 15: Text blocks for multi-line strings

Triple-quoted text blocks keep JSON, SQL and HTML readable without escapes.

Code
String json = """
        {
          "name": "Ava",
          "role": "admin"
        }""";
System.out.println(json);
Output
{
  "name": "Ava",
  "role": "admin"
}
Advertisement

Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.

Published 2026-07-26