Class TextBlockExamples
java.lang.Object
net.jrodolfo.java_evolution.java15.TextBlockExamples
Demonstrates text blocks, finalized in Java 15.
Before text blocks, multi-line strings required newline escapes, concatenation, and careful indentation. That made embedded JSON, SQL, HTML, and other structured text hard to read in Java source code.
Text blocks solve this by making multi-line string literals readable and maintainable. Java 15 finalized the feature after previews in Java 13 and Java 14.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionformattedSummary(int version, String feature) UsesString.formatted(Object...)with a text block template.json()Creates JSON using a text block.
-
Constructor Details
-
TextBlockExamples
public TextBlockExamples()
-
-
Method Details
-
json
-
formattedSummary
UsesString.formatted(Object...)with a text block template.- Parameters:
version- the Java versionfeature- the feature name- Returns:
- formatted multi-line text
-