Text Blocks (introduced in Java 15)
Text blocks simplify the creation and formatting of multiline strings. They allow you to write strings with line breaks and indentation without the need for escape sequences or concatenation. Here's an example:
String html = """
<html>
<body>
<h1>Welcome to my website!</h1>
<p>This is a paragraph of text.</p>
</body>
</html>
""";
No comments:
Post a Comment