Multiline JSON/SQL/HTML
Write SQL, JSON, and HTML as they actually look.
Code Comparison
✕ Java 8
String sql =
"SELECT u.name, u.email\n" +
"FROM users u\n" +
"WHERE u.active = true\n" +
"ORDER BY u.name";
✓ Java 15+
String sql = """
SELECT u.name, u.email
FROM users u
WHERE u.active = true
ORDER BY u.name""";
Why the modern way wins
Copy-paste
Paste SQL/JSON directly from other tools.
Readable
The string looks like the actual SQL/JSON output.
Maintainable
Easy to edit — no hunting for \n and + operators.
Old Approach
Escaped Strings
Modern Approach
Text Blocks
Since JDK
15
Difficulty
beginner
JDK Support
Multiline JSON/SQL/HTML
Available
Widely available since JDK 15 (Sept 2020)
How it works
Text blocks make embedded languages readable. Copy SQL from your database tool and paste it directly. The closing delimiter position controls indentation stripping.