

#NUMBER OF TEXT BLOCKS IN THOMAS CODE#
Here's an example of a snippet of Java code within a text block: String source = """ This last example is equivalent to the following string literal: String name = "red\n" +

Handling rules (see the section below, Incidental White Space). Requiring the initial line terminator simplifies the indentation The reason for this is that textīlocks are primarily designed to support multi-line strings, and The contents of the text block follow the three opening double-quotes You can't put a text block on a single line, nor can Of shoes - and ships - and sealing-wax -Ī text block begins with three double-quote characters followed by a Using text blocks removes much of the clutter: // BETTER "Of shoes - and ships - and sealing-wax -\n" + String message = "'The time has come,' the Walrus said,\n" + In this case there isĬonsiderable clutter from quotation marks, newline escapes, and Literal is used to represent a multi-line string. Smith""".substring(8).equals("Smith") // trueĪ text block can be used in place of a string literal to improve the String methods may be applied to a text block: """ Text blocks may be used as a method argument: (""" String together = str + " and " + tb + "." ForĮxample, text blocks may be intermixed with string literals in a stringĬoncatentation expression: String str = "The old" Text blocks can be used anywhere a string literal can be used. Both dqName and tbName intern to the same string Continuing with dqName and tbName from the examples above, // Both dqName and tbName are strings of equal value This includes object representation and interning. With the same characteristics as a traditional double quoted string. The object produced from a text block is a That can be used anywhere a traditional double quoted string literal canīe used. Obstructions, allowing you to embed code snippets and text sequencesĪ text block is an alternative form of Java string representation Required a tangled mess of explicit line terminators, stringĬoncatenations, and delimiters. In earlier releases of the JDK, embedding multi-line code snippets This guide assembles practical usage advice for text blocks, along withĪ text block's principalis munus is to provide clarity by way of minimizing the Java syntax required to render a string that spans multiple lines.

While the JEP explains the feature in greatĭetail, it's not always apparent how the feature can and should be used. JEP 378 adds the language feature text blocks

The long quotation is indented half an inch from the rest of the text, so it looks like a block of text.The line before your long quotation, when you're introducing the quote, usually ends with a colon.There are 4 rules that apply to long quotations that are different from regular quotations: If your quotation extends to more than four lines as you're typing your essay, it is a long quotation.
