It looks like moving the closing delimiter to the left or the content to the right has the same effect: additional indentation of the final string. The last two examples are a little less obvious. The second example shows that putting a text block's closing delimiter on its own line appends a newline to the end of the resulting string. """ ) // > Hello, multiline text blocks! // > """ ) // > Hello, multiline text blocks! // > System. Hello, multiline text blocks!""" ) // > Hello, multiline text blocks! System. We'll come to placing the closing """ in a second. ends with three double quotation marks """ (that's the closing delimiter) - these can be on the last line of content or on their own line, which makes a difference.begins with three double quotation marks """ and a newline (that's the opening delimiter).accepted in the exact same places where a string literal "like this one" is accepted.Let's start with getting text blocks past the compiler: If you know similar features from other languages, channel your inner Duke and ignore them for a moment to free your mind for Java's variant. Raw strings are on the table, though, and thanks to the fast releases we may see them as early as 2020.īut that's for another post - in this one we'll dive into text blocks. Text blocks are a straightforward feature (introduced by JEP 355) without any bells and whistles: no raw strings and no variable or even expression interpolation - all we get now are literals that span several lines.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |