Language Początkujący

Write multiline strings naturally with triple-quote text blocks.

✕ Java 8
String json = "{\n" +
    "  \"name\": \"Duke\",\n" +
    "  \"age\": 30\n" +
    "}";
✓ Java 15+
String json = """
    {
      "name": "Duke",
      "age": 30
    }""";
Widzisz problem z tym kodem? Daj nam znać.
📖

Readable as-is

JSON, SQL, and HTML look like real JSON, SQL, and HTML in your source.

🚫

No escape hell

Embedded quotes don't need backslash escaping.

📐

Smart indentation

Leading whitespace is trimmed automatically based on the closing delimiter position.

Stare podejście
String Concatenation
Nowoczesne podejście
Text Blocks
Od JDK
15
Poziom trudności
Początkujący
Text blocks for multiline strings
Dostępne

Widely available since JDK 15 (Sept 2020)

Text blocks let you write multiline strings exactly as they appear. No more escaping quotes or adding \n. The compiler strips incidental indentation automatically.

Udostępnij 𝕏 🦋 in