Text Block allows to write multiline strings easily without using rn. The content ends at the last character before the first double quote of the closing delimiter. Java 13 introduces text blocks to handle multiline strings like JSON/XML/HTML etc. Text blocks are still String data type which means you can store them inside String variable and apply all kinds of String functions like length(). Each example prints the text block to show you the resulting string: This text block is the. The content of a text block can span multiple lines, and you do not need to use most escape sequences. The closing delimiter is a sequence of three double quote characters. A text block is a sequence of zero or more characters enclosed by an opening delimiter and a closing delimiter. The content begins at the first character after the line terminator of the opening delimiter. In a text block, the opening delimiter is a sequence of three double quote characters (""") followed by zero or more white spaces followed by a line terminator. This is a preview language feature in JDK 13. Summary - Add text blocks to the Java language. automatically formats the string in a predictable way, and gives the developer control over format when desired.That means we don't have to escape character like double quote (") avoids the need for most escape sequences.a multi-line string literal that can be written without + concatenation.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |