Class TextBlockPreviewExamples

java.lang.Object
net.jrodolfo.java_evolution.java13.TextBlockPreviewExamples

public class TextBlockPreviewExamples extends Object
Demonstrates text blocks as a Java 13 preview feature.

Before text blocks, multi-line strings required repeated quotes, newline escapes, concatenation, and manual indentation. That made embedded JSON, SQL, HTML, and XML harder to read.

Java 13 previewed text blocks to solve that readability problem. Text blocks became final later, in Java 15. This project compiles on JDK 25, so the example uses final syntax while documenting the Java 13 preview origin.

  • Constructor Details

    • TextBlockPreviewExamples

      public TextBlockPreviewExamples()
  • Method Details

    • jsonTextBlock

      public String jsonTextBlock()
      Uses a text block for readable multi-line JSON.
      Returns:
      JSON text
    • sqlTextBlock

      public String sqlTextBlock()
      Uses a text block for readable SQL.
      Returns:
      SQL text