![]() ![]() After being in preview in JDK 13 and 14 with Java 15 its the Prime Time for Text Blocks. Java 13 has delivered the long-awaited multiline strings or Text Blocks.You no longer need to concatenate strings that span multiple lines or escape special characters, which really improves the readability of your code. A text block is an alternative form of Java string representation that can be used anywhere a traditional double quoted string literal can be used. Text blocks were initially planned for Java 12 but this feature generated a lot of debates inside the Java Community and its introduction has been postponed. It starts and ends with a """ (three double-quotes marks) e.g. Text blocks eliminate most of these obstructions, allowing you to embed code snippets and text sequences more or less as-is. Recommended further reading: Text Blocks by Brian Goetz. They can greatly improve the readability of embedded strings like JSON, XML or SQL by supporting multiple lines a removing the need for double quote escaping. We can use Text Blocks to write multi-line strings in our programs, without bothering about any escape. ![]() A text block is a multi-line string literal and the feature offers a clean way to format the string in a predictable way, without using most of the escape sequences. Text blocks are a nice addition to the Java programming language. The Java Text Blocks is a new feature of String literal.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |