GitHub
The Java Version Almanac
javaalmanac.io
Feedback on this page?

Text Blocks

Text blocks allow multiline strings literals.

Since Java 15

public class TextBlocks { static final String LINK_TEMPLATE = """ <a href="%s">Click here!</a>"""; void main() { // Text blocks always start with three double quotes and a new line: String greeting = """ Hello "World"! """; IO.println(greeting); IO.println(LINK_TEMPLATE.formatted("https://javaalmanac.io/")); } }

This snippet at GitHub