A text block's common leading whitespace is stripped using the least-indented line, including the closing triple-quote, so moving the closing delimiter changes how much indentation survives.
String block = """
Hello
World
""";
System.out.println("[" + block + "]");
System.out.println("Length: " + block.length());
[Hello
World
]
Length: 14
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-09-27