Skip to content

Latest commit

 

History

History
36 lines (13 loc) · 721 Bytes

Text Blocks with Format Specifiers.md

File metadata and controls

36 lines (13 loc) · 721 Bytes

Text Blocks with Format Specifiers

j

Java 16 introduced an enhancement to text blocks that allows for the inclusion of format specifiers within the text block. This feature allows for the easy formatting of text within the text block.

Example:

String message = """

              Dear %s,

              

              Thank you for your recent order.

              Your order number is %d.

              

              Regards,

              The Store

              """;

String formatted = String.format(message, "John", 12345);

System.out.println(formatted);